English 中文(简体)
XSLT转化过程中的孤独替罪
原标题:Unescape during XSLT transform

I m 利用Saxon, XSLT 2.0 合规,将使用XSLT的XML文件转换成XVD。

Within my XML documents I have nodes like so (truncated here for brevity):

  <script type="text/javascript"> 
  document.write( &lt;script&gt; )
  </script> 

我想能够做的是,将越狱的特征归为无遗的,因此,<代码>和>;改为<&gt;改为>,最好是在文字点内出现。

最后产出如下:

  <script type="text/javascript"> 
  document.write( <script> )
  </script> 

这是可能的,也是对如何?

最佳回答

html 序列化方法>,script 内容没有消失。

http://www.w3.org/TR/xslt#section-spanish-Output-Method”rel=“nofollow”http://www.w3.org/TR/xslt#section-spanish-Output-Method

The html output method should not perform escaping for the content of the script and style elements

Update

As Dr. @ Michael Kay已评论说,如果你为浏览器制造X超文本(并配送正确的监听器类型),那么你就不必担心无动于衷。 此外,应当指出,在线文字不被认为是良好做法。

如果你仍然希望按照关于遗产浏览器的准则,以<代码>xml序列化方法,你可以宣布<代码>> > > > 封面内容为光盘传输系统。

http://www.w3.org/TR/xslt#section-XML-Output-Method” rel=“nofollow” http://www.w3.org/TR/xslt#section-XML-Output-Method

The cdata-section-elements attribute contains a whitespace-separated list of QNames. Each QName is expanded into an expanded-name using the namespace declarations in effect on the xsl:output element in which the QName occurs; if there is a default namespace, it is used for QNames that do not have a prefix. The expansion is performed before the merging of multiple xsl:output elements into a single effective xsl:output element. If the expanded-name of the parent of a text node is a member of the list, then the text node should be output as a CDATA section

例如:

<xsl:output cdata-section-elements="xhtml:script xhtml:style"
            xmlns:xhtml="http://www.w3.org/1999/xhtml"/>
问题回答




相关问题
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

热门标签