Merging two XML files using XSLT

后端 未结 2 828
醉酒成梦
醉酒成梦 2021-01-12 16:00

I have 2 xml files which I need to merge together using a style sheet


  ...
  

        
相关标签:
2条回答
  • 2021-01-12 16:08

    You should be replace your line as below:-

    <xsl:param name="ApplicationData" select="/"/>
      <xsl:param name="MetricList"/>
    

    with this below line one:

       <xsl:variable name="Application_Data" select="document('Application_Data.xml')/ApplicationData"/>
     <xsl:variable name="'Metric_List" select="document('Application_Data.xml')/MetricList"/>
    

    i think this may help you..

    0 讨论(0)
  • 2021-01-12 16:26

    Given the following input files:

    ApplicationData.xml

    <?xml version="1.0" ?>
    <ApplicationData>
        Whatever data you have in here.
    </ApplicationData>
    

    MetricList.xml

    <?xml version="1.0" ?>
    <MetricList>
        Whatever list you have in here.
    </MetricList>
    

    AssessmentInput.xml

    <?xml version="1.0" ?>
    <AssessmentInput />
    

    the following transformation merge.xsl applied to AssessmentInput.xml

    <?xml version="1.0" ?>
    <xsl:transform
        xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
        version="1.0">
        <xsl:template match="/AssessmentInput">
            <xsl:copy>
                <xsl:copy-of select="document('ApplicationData.xml')" />
                <xsl:copy-of select="document('MetricList.xml')" />
            </xsl:copy>
        </xsl:template>
    </xsl:transform>
    

    produces the correct output of

    <?xml version="1.0" encoding="UTF-8"?>
    <AssessmentInput>
        <ApplicationData>
            Whatever data you have in here.
        </ApplicationData>
        <MetricList>
            Whatever list you have in here.
        </MetricList>
    </AssessmentInput>
    
    0 讨论(0)
提交回复
热议问题