Xslt XSL和名称空间
使用php xlst处理器分析以下内容会导致此错误:Xslt XSL和名称空间,xslt,Xslt,使用php xlst处理器分析以下内容会导致此错误: `Warning: DOMDocument::load(): Namespace prefix g on id is not defined in /var/www /mistermatic/spider/resources/xslt/car/google.xsl, line: 32 in /var/www/mistermatic/ads/PublicXML/makeXML.php on line 91` 如何在rss节点内正确定义名
`Warning: DOMDocument::load(): Namespace prefix g on id is not defined in /var/www /mistermatic/spider/resources/xslt/car/google.xsl, line: 32 in /var/www/mistermatic/ads/PublicXML/makeXML.php on line 91`
如何在rss节点内正确定义名称空间,以便将其应用于所有要操作的子节点
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:strip-space elements="*"/>
<xsl:output method="xml" version="1.0" encoding="UTF-8" omit-xml-declaration="no" indent="yes"/>
<xsl:template match="/">
<rss xmlns:g="http://base.google.com/ns/1.0" version="2.0">
<channel>
<title>Mistermatic</title>
<link>http://www.mistermatic.it</link>
<description>Multipubblicazione di annunci di automobili nuove ed usate</description>
<xsl:for-each select="//ad">
<item xmlns:g="http://base.google.com/ns/1.0" version="2.0">
<xsl:apply-templates select="itemId"/>
<g:availability>in stock</g:availability>
<g:google_product_category><![CDATA[Veicoli a motore > Veicoli > Auto, autocarri e furgoni]]></g:google_product_category>
</item>
</xsl:for-each>
</channel>
</rss>
</xsl:template>
<xsl:template match="itemId">
<g:id>
<xsl:text disable-output-escaping="yes"><![CDATA[</xsl:text>
<xsl:value-of select="@value"/>
<xsl:text disable-output-escaping="yes">]]></xsl:text>
</g:id>
</xsl:template>
</xsl:stylesheet>
冷淡的
http://www.mistermatic.it
新使用的汽车年鉴多管齐下
有现货的
Veicoli>自动、自动传送furgoni]>
![CDATA[
]]
将xmlns:g
声明向上移动到xsl:stylesheet
元素,使其在整个样式表中可见。问题是您在rss
元素中定义了名称空间,但是,它在XSLT文件的其他位置使用。尝试将名称空间定义移动到XSLT文档的根目录。好的,在根目录中移动xlmns声明如下:
我是通过php得到的:警告:XSLTProcessor::importStylesheet():xsl:version:etc中只支持1.0功能!!!如何在版本2.0中定义google xmlns并将xsl xmlns保持在版本1.0中?请在rss元素上保留version=“2.0”
,只移动xmnls:g
。