XSLT:管道文档

XSLT : pipeDocument

设置: Apache Xalan 2.7.1

输入:

<?xml version="1.0" encoding="UTF-8"?>
<note>
    <to>Tove</to>
    <from>Jani</from>
    <heading>Reminder</heading>
    <body>Don't forget me this weekend!</body>
</note>

main.xslt:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" 
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:xpi="http://xml.apache.org/xalan/PipeDocument">
    <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>


  <xsl:template match="/">  
        <xpi:pipeDocument source="." >
               <stylesheet href="second.xslt"/>
        </xpi:pipeDocument>
  </xsl:template>

</xsl:stylesheet>

second.xslt :

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" 
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>

    <xsl:template match="/">    
        <xsl:value-of select="note/to" />
    </xsl:template>

</xsl:stylesheet>

输出:

<?xml version="1.0" encoding="UTF-8"?><xpi:pipeDocument xmlns:xpi="http://xml.apache.org/xalan/PipeDocument" source=".">
<stylesheet href="second.xslt"/>
</xpi:pipeDocument>

期望输出:

<?xml version="1.0" encoding="UTF-8"?>
Tove

Question :

Comming from here: https://xml.apache.org/xalan-j/apidocs/org/apache/xalan/lib/PipeDocument.html

I really scratch my head about this one. How to properly use source and target??

I wish to have currently input xml as source and output just as it was, standard output.xml.

Note: Only xslt 1.0 solutions are appreciated

考虑以下模板作为答案

Note that you need to have proper folder structure in order for this transformation to work. (second.xslt, thrid.xslt, output, input xmls)

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" 
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:xpi="http://xml.apache.org/xalan/PipeDocument"
    extension-element-prefixes="xpi">
    <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes" />


  <xsl:template match="/">      
        <xpi:pipeDocument source="'source_file'" target="output_file">
               <stylesheet href="second.xslt"/>
               <stylesheet href="third.xslt"/>
        </xpi:pipeDocument>
    </xsl:template>


</xsl:stylesheet>