【发布时间】:2019-10-09 11:14:21
【问题描述】:
我正在使用 xslt 从中生成 xml 文件。 问题是输出 xml 像这样添加了命名空间:xmlns=""。 我不想要它,因为 beanio.org 不适用于命名空间,我如何从输出 xml 中删除 xmlns=""? xslt
<xsl:template match="/">
<beanio xmlns="http://www.beanio.org/2012/03"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.beanio.org/2012/03 http://www.beanio.org/2012/03/mapping.xsd">
<xsl:choose>
<xsl:when test="/FeedFileConfig/@delimiter">
<xsl:element name="stream">
<xsl:attribute name="name">
<xsl:text>record</xsl:text>
</xsl:attribute>
<xsl:attribute name="format">
<xsl:text>csv</xsl:text>
</xsl:attribute>
<xsl:attribute name="ignoreUnidentifiedRecords">
<xsl:text>true</xsl:text>
</xsl:attribute>
<xsl:attribute name="xmlNamespace">
<xsl:text>http://www.beanio.org/2012/03</xsl:text>
</xsl:attribute>
<xsl:element name="parser">
<xsl:element name="property">
<xsl:attribute name="name">
<xsl:text>delimiter</xsl:text>
</xsl:attribute>
<xsl:attribute name="value">
<xsl:value-of select="/FeedFileConfig/@delimiter" />
</xsl:attribute>
</xsl:element>
</xsl:element>
<xsl:apply-templates />
</xsl:element>
</xsl:when>
<xsl:otherwise>
<xsl:element name="stream">
<xsl:attribute name="name">
<xsl:text>record</xsl:text>
</xsl:attribute>
<xsl:attribute name="format">
<xsl:text>fixedlength</xsl:text>
</xsl:attribute>
<xsl:attribute name="ignoreUnidentifiedRecords">
<xsl:text>true</xsl:text>
</xsl:attribute>
<xsl:attribute name="xmlNamespace">
<xsl:text>http://www.beanio.org/2012/03</xsl:text>
</xsl:attribute>
</xsl:element>
<xsl:apply-templates />
</xsl:otherwise>
</xsl:choose>
</beanio>
</xsl:template>
<xsl:template match="FeedFileConfig">
<xsl:for-each select="/FeedFileConfig/Parsers/Parser">
<xsl:element name="record">
<xsl:attribute name="name">
<xsl:value-of select="@name" />
</xsl:attribute>
<xsl:attribute name="class">
<xsl:value-of select="'map'" />
</xsl:attribute>
<xsl:attribute name="xmlNamespace">
<xsl:text>http://www.beanio.org/2012/03</xsl:text>
</xsl:attribute>
<xsl:for-each select="Fields/Field">
<xsl:variable name="varJsonPath">
<xsl:value-of select="replace(@jsonPath, '\$\.', '')" />
</xsl:variable>
<xsl:variable name="varIgnore">
<xsl:value-of select="@ignore" />
</xsl:variable>
<xsl:variable name="varLength">
<xsl:value-of select="@length" />
</xsl:variable>
<xsl:if test="@jsonPath != '$.recordType'">
<xsl:element name="field">
<xsl:attribute name="name">
<xsl:value-of select="$varJsonPath" />
</xsl:attribute>
<xsl:if test="$varLength != ''">
<xsl:attribute name="length">
<xsl:value-of select="@length" />
</xsl:attribute>
</xsl:if>
<xsl:if test="$varIgnore != ''">
<xsl:attribute name="ignore">
<xsl:value-of select="$varIgnore" />
</xsl:attribute>
</xsl:if>
</xsl:element>
</xsl:if>
<xsl:if test="@jsonPath = '$.recordType'">
<xsl:element name="field">
<xsl:attribute name="name">
<xsl:value-of select="$varJsonPath" />
</xsl:attribute>
<xsl:attribute name="rid">
<xsl:value-of select="'true'" />
</xsl:attribute>
<xsl:attribute name="regex">
<xsl:value-of
select="../../Filters/Filter/@regex" />
</xsl:attribute>
<xsl:if test="$varLength != ''">
<xsl:attribute name="length">
<xsl:value-of select="@length" />
</xsl:attribute>
</xsl:if>
<xsl:if test="$varIgnore != ''">
<xsl:attribute name="ignore">
<xsl:value-of select="$varIgnore" />
</xsl:attribute>
</xsl:if>
</xsl:element>
</xsl:if>
</xsl:for-each>
</xsl:element>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
我正在使用 xslt 从中生成 xml 文件。 问题是输出 xml 像这样添加了命名空间:xmlns=""。 我不想要它,因为 beanio.org 不适用于命名空间,如何从输出 xml 中删除 xmlns=""?
<?xml version="1.0" encoding="UTF-8"?>
<beanio xmlns="http://www.beanio.org/2012/03"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.beanio.org/2012/03 http://www.beanio.org/2012/03/mapping.xsd">
<stream name="record" format="csv" ignoreUnidentifiedRecords="true"
xmlNamespace="http://www.beanio.org/2012/03">
<parser>
<property name="delimiter" value=";"/>
</parser>
<record xmlns="" name="asbmasteranddeltafile" class="map"
xmlNamespace="http://www.beanio.org/2012/03">
<field name="isin"/>
<field name="status"/>
<field name="instrumentCategory"/>
<field name="issueDescription"/>
<field name="cfiCode"/>
<field name="fisn"/>
<field name="preliminaryTermsProspectus"/>
<field name="nominalValue"/>
<field name="issueCurrency"/>
<field name="smallestDenomination"/>
<field name="conversionRatioContractSize"/>
<field name="maturityExpirationDate"/>
<field name="exercisePrice"/>
<field name="exercisePriceCurrency"/>
<field name="underlying"/>
<field name="typeOfInterest"/>
<field name="interestRate"/>
<field name="interestPaymentDate"/>
<field name="interestFrequency"/>
<field name="firstInterestPaymentDate"/>
<field name="additionalInformation"/>
<field name="marketIdentifierCodeMic"/>
<field name="leadManagerName"/>
<field name="leadManagerLei"/>
<field name="fundManagerName"/>
<field name="fundManagerLei"/>
<field name="centralSecurityDepositoryCsdNameCentralSecurityDepositoryCsdLei"/>
<field name="issuerNameLong"/>
<field name="issuerLei"/>
<field name="issuerNameShort"/>
<field name="issuerSupranational"/>
<field name="issuerHeadquartersAddress1"/>
<field name="issuerHeadquartersAddress2"/>
<field name="issuerHeadquartersStateProvince"/>
<field name="issuerHeadquartersPostCode"/>
<field name="issuerHeadquartersCity"/>
<field name="issuerHeadquartersCountry"/>
<field name="issuerLegalRegistrationAddress1"/>
<field name="issuerLegalRegistrationAddress2"/>
<field name="issuerLegalRegistrationStateProvince"/>
<field name="issuerLegalRegistrationPostCode"/>
<field name="issuerLegalRegistrationCity"/>
<field name="issuerLegalRegistrationCountry"/>
<field name="createDate"/>
<field name="modifyDate"/>
</record>
</stream>
</beanio>
我正在使用 xslt 从中生成 xml 文件。 问题是输出 xml 像这样添加了命名空间:xmlns=""。 我不想要它,因为 beanio.org 不适用于命名空间,如何从输出 xml 中删除 xmlns=""?
【问题讨论】:
-
请编辑您的问题,以便我们清楚地看到您的输入和预期输出。