Php XSLT转换,名称空间错误
我尝试使用XSLT处理器在PHP中转换xml文档,但我无法选择任何内容。。。我认为这是一个名称空间问题。如果我从一个干净的Php XSLT转换,名称空间错误,php,xml,xslt,xpath,Php,Xml,Xslt,Xpath,我尝试使用XSLT处理器在PHP中转换xml文档,但我无法选择任何内容。。。我认为这是一个名称空间问题。如果我从一个干净的开始,那么转换工作正常 inputxml: <?xml version="1.0" encoding="utf-8"?> <products xmlns="http://***.net/schemata/base" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation
开始,那么转换工作正常
inputxml:
<?xml version="1.0" encoding="utf-8"?>
<products xmlns="http://***.net/schemata/base" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://***.net/schemata/base/products.xsd">
<product ean="4260094730238" eol="false" model="1090017" status="true">
<ean>4260094730238</ean>
<eol>false</eol>
<group>screens</group>
<model>1090017</model>
<status>true</status>
</product>
</products>
4260094730238
假的
屏风
1090017
真的
Xsl文件:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="xml" encoding="UTF-8" indent="yes"/>
<xsl:template match="/">
<ARTICLE>
<SUPPLIER_AID>
<xsl:value-of select="products/product/ean" />
</SUPPLIER_AID>
</ARTICLE>
</xsl:template>
</xsl:stylesheet>
我无法更改inputfile,因为它是由其他程序生成的
Andre更改XSLT以使用输入XML中的默认名称空间,如下所示:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" xmlns:my="http://***.net/schemata/base" exclude-result-prefixes="my">
<xsl:output method="xml" encoding="UTF-8" indent="yes"/>
<xsl:template match="/">
<ARTICLE>
<SUPPLIER_AID>
<xsl:value-of select="my:products/my:product/my:ean" />
</SUPPLIER_AID>
</ARTICLE>
</xsl:template>
</xsl:stylesheet>
谢谢。这对我来说太完美了。