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

Subject: Re: [xsl] creating multiple xml documents from one large xml document
From: "LEGAULT, PHILLIP plegault@xxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Fri, 26 May 2023 22:48:05 -0000
Hi Martin,
Ibm using Saxon XSLT 2

Calling it like: xslt2 soap.xml file.xsl hello.htm

<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
    xmlns:sf="urn:sobject.enterprise.soap.sforce.com"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";>
<xsl:template match="records[@xsi:type = 'sf:CaseNote_GCC__c']">
   <xsl:result-document href="case-{sf:Id}-{sf:CaseNumber}.xml">
     <xsl:copy-of select="."/>
  </xsl:result-document>
</xsl:template>
</xsl:stylesheet>


Not getting any result files.



From: Martin Honnen martin.honnen@xxxxxx
<xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Sent: Friday, May 26, 2023 4:42 PM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: [EXTERNAL] Re: [xsl] creating multiple xml documents from one large
xml document



On 5/26/2023 9:50 PM, LEGAULT, PHILLIP
plegault@xxxxxxxxxx<mailto: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.



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

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

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

  </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.
XSL-List info and archive<http://www.mulberrytech.com/xsl/xsl-list>
EasyUnsubscribe<http://lists.mulberrytech.com/unsub/xsl-list/3514465> (by
email<>)

Current Thread