如何用xsl转换多值xml属性
我需要使用xsl将xml转换为普通xml,从:如何用xsl转换多值xml属性,xml,xslt,Xml,Xslt,我需要使用xsl将xml转换为普通xml,从: <LongAssetInfoMulti attrTagName.s="tagName" attrName.s="tagName" values.ll="14491 14553 14568 14581 15239 15240 15241"/> 致: 我做好了准备: <xsl:template match="/"> <xsl:variable name="test" select="//LongAssetInfo
<LongAssetInfoMulti attrTagName.s="tagName" attrName.s="tagName" values.ll="14491 14553 14568 14581 15239 15240 15241"/>
致:
我做好了准备:
<xsl:template match="/">
<xsl:variable name="test" select="//LongAssetInfoMulti/@values.ll"/>
<xsl:for-each select="$test">
<xsl:value-of select="$test"></xsl:value-of>
</xsl:for-each>
</xsl:template>
有人知道如何解析多个属性值吗?正如michael.hor257k所说,我们可以使用标记化,如下所示:
<xsl:stylesheet version="3.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:ext="http://www.courts.state.mn.us/ProtectionOrderExtension/1.0" xmlns:nc="http://niem.gov/niem/niem-core/2.0" extension-element-prefixes="ext nc" exclude-result-prefixes="mscef msxsl exsl ext">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:template match="/">
<xsl:variable name="test" select="//LongAssetInfoMulti/@values.ll"/>
<xsl:for-each select="tokenize($test, ' ')">
<xsl:sort select="$test"/>
<tagname>
<xsl:value-of select="."/>
</tagname>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
您需要标记这些值。您使用的是哪个XSLT处理器?
<xsl:stylesheet version="3.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:ext="http://www.courts.state.mn.us/ProtectionOrderExtension/1.0" xmlns:nc="http://niem.gov/niem/niem-core/2.0" extension-element-prefixes="ext nc" exclude-result-prefixes="mscef msxsl exsl ext">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:template match="/">
<xsl:variable name="test" select="//LongAssetInfoMulti/@values.ll"/>
<xsl:for-each select="tokenize($test, ' ')">
<xsl:sort select="$test"/>
<tagname>
<xsl:value-of select="."/>
</tagname>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>