How to join 2 XSL codes in a single XSL file

拟墨画扇 提交于 2020-03-06 09:31:40

问题


I have provided the input and desired expected xml in another question at the below link: How to re-arrange xml using xslt with repeated xml nodes

Request to please let me know how to join the below 2 XSL codes in a single XSL file so that it works on my input xml.

Code for 'INFONAMEADDRESSMANUFACTPLANT' Node:

    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
    <xsl:output method="xml" indent="yes"/>
    <xsl:strip-space elements="*" />
<xsl:template match="@*|node()">
        <xsl:copy>
            <xsl:apply-templates select="@*|node()"/>
        </xsl:copy>
</xsl:template>
<xsl:template match="INFONAMEADDRESSMANUFACTPLANT" />
<xsl:template match="INFONOTE">
    <xsl:copy>
        <xsl:apply-templates select="@*|node()"/>
        <INFONAMEADDRESSMANUFACTPLANT>
        <VARIABLELABEL>IFM</VARIABLELABEL>      
            <xsl:for-each select="INFONAMEADDRESSMANUFACTPLANT">                     
                <xsl:copy-of select="SERIALNO1" />
                <xsl:copy-of select="SPONSOR_NAME" />
                <xsl:copy-of select="SPONSOR_ADDRESS1" />
                <xsl:copy-of select="SPONSOR_ADDRESS2" />
                <xsl:copy-of select="MANUFACTURERIMPORTERCODE" />
             </xsl:for-each>
        </INFONAMEADDRESSMANUFACTPLANT>
    </xsl:copy>
  </xsl:template>
</xsl:stylesheet>

Code for 'INFOPERSONFILLNOTE' node:

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

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

<xsl:template match="INFOPERSONFILLNOTE">
    <xsl:copy>
        <xsl:apply-templates select="@*"/>
        <xsl:apply-templates select="VARIABLELABEL"/>

        <xsl:for-each select="SERIALNO1|CLASSPERSONFILLNOTE">
            <xsl:sort select="number(translate(VARIABLELABEL, 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz', ''))" order="ascending"/>
            <xsl:copy><xsl:apply-templates select="@*|node()"/></xsl:copy>
        </xsl:for-each>
    </xsl:copy>
</xsl:template>

</xsl:stylesheet>

Please help.

来源:https://stackoverflow.com/questions/60144910/how-to-join-2-xsl-codes-in-a-single-xsl-file

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!