sujith90
sujith90

Reputation: 37

XSLT to output multiple XML Files in a single pass

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.

Upvotes: 1

Views: 77

Answers (1)

Michael Kay
Michael Kay

Reputation: 163262

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.

Upvotes: 1

Related Questions