how to include script tag in an xsl file?

前端 未结 7 2050
遥遥无期
遥遥无期 2021-02-14 13:08

I\'m working on an old site that uses java and xsl. How can I inculde a script file in an xsl file? Top of the file:



        
相关标签:
7条回答
  • 2021-02-14 14:08

    EDITED

    Here is a solution that works

    Assuming this is your xsl and you are including xsl as you mentioned. In this case I called it include.xsl. I just call a template called headers that pipes out the javascript reference.

    Main XSLT File:

    <?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
     version="1.0">
        <xsl:include href="include.xsl"/>
    
        <xsl:template match="/">
            <xsl:call-template name="headers"/>
            <bar>
               <xsl:value-of select="root"/>
            </bar>
        </xsl:template>
    </xsl:stylesheet>
    

    include.xsl

    <?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    version="1.0">
       <xsl:template name="headers">
            <script src="/fs/scripts/shipment/shipment.js"></script>
       </xsl:template>
    </xsl:stylesheet>
    

    Output:

    <?xml version="1.0" encoding="utf-8"?>
    <script src="/fs/scripts/shipment/shipment.js"/>
    <bar>foo</bar>
    
    0 讨论(0)
提交回复
热议问题