English 中文(简体)
如何从XSL的特性中脱下疫苗?
原标题:How do I strip accents from characters in XSL?

我一直在研究,但可以发现一种类似于“热空间”的XSL功能。 这就是说,我的内容突出了联合国民主运动的特征,这种特性是巨大的,但从这一内容来看,我制造了一个档案名称,我不希望这些表象。

因此,我看不出,或者说不恰当地去做什么来轻松地处理特征?

在XML数据中:

<filename>gri_gonéwiththèw00mitc</filename>

In XSLT stylesheet:

<xsl:variable name="file">
    <xsl:value-of select="filename"/>
</xsl:variable>

<xsl:value-of select="$file"/>

“农业”成果

地点

<xsl:value-of select= replace( normalize-unicode( "$file", "NFKD" ), "[^\p{ASCII}]", "" ) />

results in nothing.

宗旨是:gri_gone withthew00mitc (no accents)

我使用了yn子错吗?

最佳回答

在XSLT/XPath 1.0中,如果你想要以无奖励的对口单位取代这些突出的特性,你可使用<代码>译文()。

但是,假设你“以联合国民主权利中心为中心”的特性是单一编码特性。 如果是这样的话,你将需要使用XPath 2.0normalize-unicode(功能。

如果真正的目标是建立一个有效的国际独立实体,则请使用encode-for-uri(

<>Update: 实例

translate( gri_gonéwiththèw00mitc , áàâäéèêëíìîïóòôöúùûü , aaaaeeeeiiiioooouuuu )

成果:gri_gone with thew00mitc

encode-for-uri( gri_gonéwiththèw00mitc )

成果:gri_gon%C3A9 withth%C3A8w00mitc

Correct expression provide suggest by @biziclop:

replace(normalize-unicode( gri_gonéwiththèw00mitc , NFKD ), P{ASCII} ,  )

成果:gri_gone with thew00mitc

<说明>::在XPath 2.0中,正确的品级否定为资本<代码>。 P 。

问题回答

因此,与我的意见相反,你可以尝试:

replace( normalize-unicode( "öt hűtőházból kértünk színhúst", "NFKD" ), "[^\p{ASCII}]", "" )

虽然有人警告说,任何可能不符合标准且为基本ASCII的特性(Norwegian ø或冰岛的Þ,例如),都将从扼杀中完全删除,但可能与你的要求格不入。

以前所建议的方法含有名称为ASCII的不知名特性类别。 在我的经验中,XPath 2.0承认“基本拉丁”这一类,该类应与ASCII相同。

replace(normalize-unicode( Lliç d Am Oükl Úkřeč ,  NFKD ),  P{IsBasicLatin} ,   )

正如尤里提到的那样,最高投票人的答复不会奏效。 IsBasic Latin 是ASCII的适当替代物

下述法典:

replace(normalize-unicode( çgri_gonéwiththèmitç , NFKD ), P{IsBasicLatin} ,  )




相关问题
how to represent it in dtd?

I have two element action and guid. guid is a required field when action is add. but when action is del it will not appear in file. How to represent this in dtd ?

.Net application configuration add xml-data

I need to add xml-content to my application configuration file. Is there a way to add it directly to the appSettings section or do I need to implement a configSection? Is it possible to add the xml ...

XStream serializing collections

I have a class structure that I would like to serialize with Xstream. The root class contains a collection of other objects (of varying types). I would like to only serialize part of the objects that ...

MS Word splits words in its XML format

I have a Word 2003 document saved as a XML in WordProcessingML format. It contains few placeholders which will be dynamically replaced by an appropriate content. But, the problem is that Word ...

Merging an XML file with a list of changes

I have two XML files that are generated by another application I have no control over. The first is a settings file, and the second is a list of changes that should be applied to the first. Main ...

How do I check if a node has no siblings?

I have a org.w3c.dom.Node object. I would like to see if it has any other siblings. Here s what I have tried: Node sibling = node.getNextSibling(); if(sibling == null) return true; else ...

Ordering a hash to xml: Rails

I m building an xml document from a hash. The xml attributes need to be in order. How can this be accomplished? hash.to_xml

热门标签