Xml XSLT头问题
当前标题Xml XSLT头问题,xml,xslt,header,namespaces,root,Xml,Xslt,Header,Namespaces,Root,当前标题 <Invoice xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="Factuur_insbou003.xsd"> 新标题 <Invoice xmlns:xs="http://www.w3.org/2001/XMLSc
<Invoice xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="Factuur_insbou003.xsd">
新标题
<Invoice xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns="http://www.gs1.nl/factuur/insbou/004"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.gs1.nl/factuur/insbou/004
Factuur_insbou004.xsd">
我试过这个:
<?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" indent="yes" encoding="UTF-8"/>
<xsl:template match="/*[local-name()= 'Invoice']">
<Invoice xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns="http://www.gs1.nl/factuur/insbou/004"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<xsl:copy-of select="node()|@*"/>
</Invoice>
</xsl:template>
</xsl:stylesheet>
您是对的(删除了错误的代码),我的问题是创建xmlns=”http://www.gs1.nl/factuur/insbou/004". 希望你能帮助我。谢谢您必须了解名称空间是文档中每个元素的限定名称的一部分,因此您需要使用例如
<xsl:template match="*">
<xsl:element name="{local-name()}">
<xsl:apply-templates select="@* | node()"/>
</xsl:element>
</xsl:template>
然后在样式表根上,您可以简单地声明所需的名称空间。但是,由于您还想向根元素添加一个属性并省略另一个属性,因此您还需要一个模板来完成这项工作,因此需要进行所有更改
<xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0"
xmlns="http://www.gs1.nl/factuur/insbou/004"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="/Invoice">
<Invoice
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xsi:schemaLocation="http://www.gs1.nl/factuur/insbou/004
Factuur_insbou004.xsd">
<xsl:apply-templates/>
</Invoice>
</xsl:template>
<xsl:template match="*">
<xsl:element name="{local-name()}">
<xsl:apply-templates select="@* | node()"/>
</xsl:element>
</xsl:template>
</xsl:transform>
问题是什么还不清楚……问题:我无法添加xmlns=“”