Unable to split and merge in XSLT

前端 未结 1 378
[愿得一人]
[愿得一人] 2021-01-27 17:23

I have an Xml

How do i remove some part of s

相关标签:
1条回答
  • 2021-01-27 17:58

    Your example is confusing. If you have an XML input such as:

    <input Inputxml="&lt;order&gt;&lt;Line PPlineNO=&quot;1&quot;&gt;Bingo&lt;/Line&gt;&lt;/order&gt;"/>
    

    where the Inputxml attribute holds the escaped XML:

    <order><Line PPlineNO="1">Bingo</Line></order> 
    

    you can use:

    <xsl:template match="input">
        <result>
            <xsl:value-of select="substring-before(substring-after(@Inputxml, 'PPlineNO=&quot;1&quot;&gt;'), '&lt;/Line&gt;')" />
        </result>
    </xsl:template>
    

    to get:

    <result>Bingo</result>
    

    Note that is not a good way to parse XML (or rather what used to be XML). It would be much smarter to unescape it first, then parse it as XML. In XSLT 3.0, you can use the parse-xml() function for this. In XSLT 1.0/2.0, you can do:

    <xsl:value-of select="@Inputxml" disable-output-escaping="yes"/>
    

    save the result to a file, and process the resulting file using another XSLT stylesheet.

    0 讨论(0)
提交回复
热议问题