English 中文(简体)
• 如何与电离层电离层电离层电离层电离层电离层电离层电离层电离层电离层电离层电离层电离层电离层电离层电离层电离层电离层电离层电离层电离层电离层电离层电离层电流。
原标题:How to XSLT-Transform a XHTML-Dokument with IE-conditional-comments?

I transform a XHTML dokument to another XML-Dokument with XSLT. In the XHTML-Input-Dokument there are several IE-conditional-comments, like this one:

<!--[if lte IE 7]>
<link rel= stylesheet  href= ie.css  type= text/css  />
<![endif]-->

But while the transformation they get lost... Even if I try only to do an identity-copy:

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

    <xsl:output method="xml" version="1.0" encoding="UTF-8" />

    <xsl:template match="@* | node()">
    <xsl:copy>
        <xsl:apply-templates select="@* | node()"/>
    </xsl:copy>
    </xsl:template>

</xsl:stylesheet>

我只拿到没有附带条件的评论的连接点。

我怎么能够用有条件的评论来复制XVD-Dokument?

问题回答

即使我只试图做身份证明:

...

I only get the link-element without the conditional comment around it.

www.un.org/Depts/DGACM/index_spanish.htm 如果情况确实如此,我怀疑,那么你正在使用一种非常精干的XSLT程序。 如果没有适当的SLT指令(配对模板<代码>comment()。

www.un.org/Depts/DGACM/index_spanish.htm 当然,我无法照搬这一“问题”,尝试了6至7个不同的异常低价竞标程序,并进行了这一转变:

<xsl:stylesheet version="1.0"
 xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
 <xsl:output omit-xml-declaration="yes" indent="yes"/>
 <xsl:strip-space elements="*"/>

 <xsl:template match="node()|@*">
     <xsl:copy>
       <xsl:apply-templates select="node()|@*"/>
     </xsl:copy>
 </xsl:template>
</xsl:stylesheet>

When applied on this XML document (the comment, wrapped in a single top element to become a well-formed XML document):

<html>
<!--[if lte IE 7]> <link rel= stylesheet  href= ie.css  type= text/css  /> <![endif]-->
</html>

www.un.org/Depts/DGACM/index_french.htm

<html>
  <!--[if lte IE 7]> <link rel= stylesheet  href= ie.css  type= text/css  /> <![endif]-->
</html>

Having said that, to generate such a "comment" is a little bit more tricky -- here is a demo how to do this:

<xsl:stylesheet version="1.0"
 xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
 <xsl:output method="xml" omit-xml-declaration="yes"/>
 <xsl:strip-space elements="*"/>

 <xsl:template match="/*">
     <html>
       <xsl:text disable-output-escaping="yes">&#xA;&lt;!--[if lte IE 7]> </xsl:text>
       <link rel= stylesheet  href= ie.css  type= text/css  />
       <xsl:text disable-output-escaping="yes"> &lt;![endif]-->&#xA;</xsl:text>
     </html>
 </xsl:template>
</xsl:stylesheet>

www.un.org/Depts/DGACM/index_spanish.htm 当这一转变适用于任何XML文件(我们的例子没有使用)时,希望产生正确的产出:

<html>
<!--[if lte IE 7]> <link rel="stylesheet" href="ie.css" type="text/css"/> <![endif]-->
</html>




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

热门标签