1

I have an XML file:

<root>
  <Person ID="123">
    <Name @name="JohnDoe"/>
    <OtherInfo>
      ......
    </OtherInfo>
  </Person>

  <Person ID="456">
    <Name @name="JaneDoe"/>
    <OtherInfo>
      ......
    </OtherInfo>
  </Person>

  <Person ID="789">
    <Name @name="JohnDoe"/>
    <OtherInfo>
      ......
    </OtherInfo>
  </Person>
</root>

I want a single XSLT file to output two files:

File1:

<root>
  <Person ID="123">
    <OtherInfo>
      ......
    </OtherInfo>
  </Person>

  <Person ID="456">
    <OtherInfo>
      ......
    </OtherInfo>
  </Person>

  <Person ID="789">
    <OtherInfo>
      ......
    </OtherInfo>
  </Person>
</root>

File2: JohnDoe, JaneDoe, JohnDoe

I want to be able to do this in a single pass through the original XML file.

1 Answer 1

1

It's easily done in XSLT 2.0 using the xsl:result-document instruction.

It's not possible in XSLT 1.0 unless your 1.0 processor has a proprietary extension equivalent to xsl:result-document.

Sign up to request clarification or add additional context in comments.

2 Comments

In XSLT 2.0, would is just be something along the lines of <xsl:result-document>
You can find some examples and explanation at etutorials.org/XML/xml+hacks/…

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.