Php CSS中的目标标记,内容类型应用程序/xhtml+;早期internet explorer的xml
下面我尝试在CSS中以标记名(span)为目标元素,但在早期的internet explorer中不起作用。。。如果有人能解决这个问题,请帮助 index.phpPhp CSS中的目标标记,内容类型应用程序/xhtml+;早期internet explorer的xml,php,internet-explorer,xslt,xhtml,xml-namespaces,Php,Internet Explorer,Xslt,Xhtml,Xml Namespaces,下面我尝试在CSS中以标记名(span)为目标元素,但在早期的internet explorer中不起作用。。。如果有人能解决这个问题,请帮助 index.php <?php header('Content-type: application/xhtml+xml'); ?> <?xml-stylesheet type="text/xsl" href="copy.xsl"?> <html xmlns="http://www.w3.org/1999/xhtml" x
<?php header('Content-type: application/xhtml+xml'); ?>
<?xml-stylesheet type="text/xsl" href="copy.xsl"?>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:aa="zz" xmlns:ee="rr">
<head>
<title></title>
<style type="text/css">
/* it work */ aa\:span{background: #00ff00;}
/* it doesnt work */ span{background: #00ff00;}
</style>
</head>
<body>
<aa:span id="span1">
<aa:p>aaa</aa:p>
</aa:span>
<ee:span id="span1">
<ee:p>aaa</ee:p>
</ee:span>
</body>
</html>
/*它工作*/aa \:span{background:#00ff00;}
/*它不起作用*/span{background:#00ff00;}
aaa
aaa
copy.xsl
<stylesheet version="1.0"
xmlns="http://www.w3.org/1999/XSL/Transform">
<template match="/">
<copy-of select="."/>
</template>
</stylesheet>
您可以将所有元素转换为纯HTML,而无需名称空间
<xsl:template match="*">
<xsl:element name="{local-name()}">
<xsl:apply-templates select="@* | node()"/>
</xsl:element>
</xsl:template>
那么你也需要
<xsl:template match="@* | comment() | text() | processing-instruction()">
<xsl:copy/>
</xsl:template>
以确保复制其他节点时保持不变
所以你们一起
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="*">
<xsl:element name="{local-name()}">
<xsl:apply-templates select="@* | node()"/>
</xsl:element>
</xsl:template>
<xsl:template match="@* | comment() | text() | processing-instruction()">
<xsl:copy/>
</xsl:template>
</xsl:stylesheet>
感谢您的反应,我只想说我是XSL新手,我用您答案的第一部分替换了copy.XSL的内容,但我不知道在哪里插入代码的第二部分(那么您还需要?或者总体上如何应用您的回答?有人可以帮助并告诉我如何继续应用@Martin Honnen发布的答案。。。?我是XSL:)的新手,所以请耐心点…@kapsula,我编辑了我的答案,向您展示了两个模板的完整样式表。首先感谢,我插入了您发布的最后一个代码,它会向我抛出一条消息(XML解析错误:前缀未绑定到名称空间位置:**第4行,第5列:-^)我添加了xmlns:XSL=“”,现在它向我抛出了一条消息(加载样式表时出错:解析XSLT样式表失败。)@kapsula,很抱歉,我从您的问题中复制了一些代码来完成样式表,但该部分与我的示例不匹配。现在更正。