生成错误的命名空间

时间:2014-07-23 05:55:07

标签: xslt xsd xslt-1.0

如果生成输出,您声明的命名空间是否可能会发生变化?是因为它获得了此架构的最后一个版本吗?

以下是我的架构中的命名空间:

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"xmlns:link="http://www.xbrl.org/2003/linkbase"xmlns="http://www.w3.org/2001/XMLSchema" xmlns:xbrli="http://www.xbrl.org/2003/instance" xmlns:gl-cor="http://www.xbrl.org/int/gl/cor/2006-10-25" targetNamespace="http://www.xbrl.org/int/gl/cor/2006-10-25" elementFormDefault="qualified" attributeFormDefault="unqualified">

,生成的输出如下:

<gl-cor:defter xmlns:gl-cor="http://www.xbrl.org/int/gl/cor/2010-04-12" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.xbrl.org/int/gl/cor/2010-04-12 gl-cor-content-2006-10-25.xsd">

如果您注意到输出中的xmlns:gl-cor的命名空间已更改为“http://www.xbrl.org/int/gl/cor/2010-04-12”。我已经检查了所有文件,并且没有宣布2010-04-12。有谁知道它发生的原因?

这是我的XSLT:

<?xml version="1.0" encoding="UTF-8"?><xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:gl-cor="http://www.xbrl.org/int/gl/cor/2010-04-12" xmlns:gl-bus="http://www.xbrl.org/int/gl/bus/2006-10-25" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:link="http://www.xbrl.org/2003/linkbase" xmlns:xbrli="http://www.xbrl.org/2003/instance">



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

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

<xsl:template match="/gl-cor:defter">
    <edefter:defter xmlns:edefter="http://www.edefter.gov.tr" 
                          xmlns:xades="http://uri.etsi.org/01903/v1.3.2#" 
                          xmlns:ds="http://www.w3.org/2000/09/xmldsig#" 
                          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
        <xsl:apply-templates select="@*|node()"/>           
    </edefter:defter>
</xsl:template>

<xsl:template match="/gl-cor:defter/gl-cor:xbrl">
        <xbrli:xbrl 
                            xmlns:iso639="http://www.xbrl.org/2005/iso639" 
                            xmlns:link="http://www.xbrl.org/2003/linkbase" 
                            xmlns:xlink="http://www.w3.org/1999/xlink" 
                            xmlns:gl-plt="http://www.xbrl.org/int/gl/plt/2006-10-25"
                            xmlns:iso4217="http://www.xbrl.org/2003/iso4217">
        <xsl:apply-templates select="@*|node()"/>
    </xbrli:xbrl>
</xsl:template>

 <xsl:template match="*[ancestor::gl-cor:entityInformation]">
    <xsl:element name="gl-bus:{local-name()}">
        <xsl:copy-of select="@*" />       
        <xsl:apply-templates />
    </xsl:element>
</xsl:template>

 <xsl:template match="*[self::gl-cor:creator]">
    <xsl:element name="gl-bus:{local-name()}">
        <xsl:copy-of select="@*" />       
        <xsl:apply-templates />
    </xsl:element>
</xsl:template></xsl:stylesheet>

和我的xml输入文件:

<gl-cor:defter xmlns:gl-cor="http://www.xbrl.org/int/gl/cor/2010-04-12" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.xbrl.org/int/gl/cor/2010-04-12 gl-cor-content-2006-10-25.xsd"><gl-cor:xbrl><gl-cor:accountingEntries><gl-cor:documentInfo><gl-cor:creator contextRef="ledger_context"></gl-cor:creator><gl-cor:entityInformation><gl-cor:entityPhoneNumber><gl-cor:phoneNumberDescription contextRef="ledger_context"></gl-cor:phoneNumberDescription>

1 个答案:

答案 0 :(得分:0)

您的XSLT只是将输入复制到输出(第一个模板是身份转换)。

由于前缀gl-cor的名称空间映射在XSLT和XML输入文件中不同,因此其他模板都不匹配。

相关问题