Re: [xsl] creating multiple xml documents from one large xml document

Subject: Re: [xsl] creating multiple xml documents from one large xml document
From: "Martin Honnen martin.honnen@xxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Fri, 26 May 2023 20:41:33 -0000
On 5/26/2023 9:50 PM, LEGAULT, PHILLIP plegault@xxxxxxxxxx wrote:
>
> Ibm working with salesforce soap xml, 3 namespaces, I am splitting
> them currently with python. I need a simpler way and hoping I can do
> it with XML.
>
> Each case has this as the beginning node and element of course with
> the end tag, for each case I want everything in between in each file.
>
> If there is no case node skip
>
> <records xsi:type="sf:CaseNote_GCC__c">
>
> Insert child node with date it was created
>
> There are 2 child nodes I want to name the file with
> <sf:Id>xxxxxxxxxxxxxx</sf:Id> and
> <sf:CaseNumber>xxxxxxxxxxx</sf:CaseNumber>
>
If you use an XSLT 2 or 3 processor (e.g. Saxon) you can easily match on
a certain element and create a result document with e.g.


 B <xsl:template match="records[@xsi:type = 'sf:CaseNote_GCC__c']">

 B B  <xsl:result-document href="case-{sf:Id}-{sf:CaseNumber}.xml">

 B B B B  <xsl:copy-of select="."/>

 B  </xsl:result-document>

</xsl:template>


I don't quite understand what you refer to with "If there is no case
node skip" but it can probably easily expressed in another predicate of
the match pattern.

Consider to show the relevant XML sample if you need more help with that.

Current Thread