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

Subject: Re: [xsl] creating multiple xml documents from one large xml document
From: "Michael Kay mike@xxxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Mon, 29 May 2023 12:13:48 -0000
Standard namespace problem (often seen with SOAP): your elements are in a
namespace

>  xmlns="urn:enterprise.soap.sforce.com
<http://enterprise.soap.sforce.com/>"

which you ignored when trying to match them.

Michael Kay
Saxonica

> On 29 May 2023, at 12:43, LEGAULT, PHILLIP plegault@xxxxxxxxxx
<xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote:
>
> This is the beginning of a case in the file, the whole case was to large to
send.
> <?xml version="1.0" encoding="UTF-8"?>
> <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/
<http://schemas.xmlsoap.org/soap/envelope/>"
>     xmlns="urn:enterprise.soap.sforce.com
<http://enterprise.soap.sforce.com/>"
>     xmlns:sf="urn:sobject.enterprise.soap.sforce.com
<http://sobject.enterprise.soap.sforce.com/>"
>     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance
<http://www.w3.org/2001/XMLSchema-instance>">
>     <soapenv:Header>
>         <LimitInfoHeader>
>             <limitInfo>
>                 <current>65</current>
>                 <limit>5000000</limit>
>                 <type>API REQUESTS</type>
>             </limitInfo>
>         </LimitInfoHeader>
>     </soapenv:Header>
>     <soapenv:Body>
>         <queryResponse>
>             <result>
>                 <done>false</done>
>                 <queryLocator>sxxx-25</queryLocator>
>                 <!-- beginning of case one -->
>                 <records xsi:type="sf:Case">
>                     <sf:Id>xxxxx</sf:Id>
>                     <sf:CaseNumber>xxxxxxxx</sf:CaseNumber>
>                     <sf:Case_Activities__r>
>                         <done>true</done>
>                         <queryLocator xsi:nil="true"/>
>                         <records xsi:type="sf:ExternalReference_GCC__c">
>                             <sf:Id xsi:nil="true"/>
>
<sf:ExternalReferenceNumber_GCC__c>xxxxxx</sf:ExternalReferenceNumber_GCC__c>
>
<sf:ExternalSource_GCC__c>dsfsffds</sf:ExternalSource_GCC__c>
>                         </records>
>                         <size>1</size>
>                     </sf:Case_Activities__r>
>                     <sf:Case_CaseNotes_GCC__r>
>                         <done>true</done>
>                         <queryLocator xsi:nil="true"/>
>                         <records xsi:type="sf:CaseNote_GCC__c">
>                             <sf:Id>a0g3L000000qNgkQAE</sf:Id>
>
<sf:CommentLanguage_GCC__c>English</sf:CommentLanguage_GCC__c>
>                             <sf:Comment_GCC__c>Test
only</sf:Comment_GCC__c>
>
<sf:LastModifiedDate>2023-05-15T13:53:47.000Z</sf:LastModifiedDate>
>                             <sf:Type_GCC__c>General</sf:Type_GCC__c>
>                         </records>
>
> From: Bauman, Syd s.bauman@xxxxxxxxxxxxxxxx
<mailto:s.bauman@xxxxxxxxxxxxxxxx> <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx
<mailto:xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>>
> Sent: Friday, May 26, 2023 9:55 PM
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
<mailto:xsl-list@xxxxxxxxxxxxxxxxxxxxxx>
> Subject: [EXTERNAL] Re: [xsl] creating multiple xml documents from one large
xml document
>
> (Confession: I did not understand the original question.)
>
> If you are not getting any result file the two most likely culprits are
> namespace problem
> you are calling the program incorrectly
> I am guessing that you are calling the xslt2b program correctly (i.e., its
signature is xslt2 [input] [stylesheet] [output]b), because if not, you
would probably get an error (like bStylesheet file is not really a
stylesheetb), not just no output.
> I notice that in the code you posted, the <records> element is being matched
as if it were in no namespace. If that is true (the <records> element(s) in
soap.xml are in no namespace), then we need to look elsewhere for a problem.
If it is not true (the <records> element(s) in soap.xml are in a namespace,
e.g. "http://www.w3.org/2003/05/soap-envelope/
<http://www.w3.org/2003/05/soap-envelope/>"), then that is the problem. Using
either
> <xsl:stylesheet version="2.0"
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform
<http://www.w3.org/1999/XSL/Transform>"
>     xmlns:sf="urn:sobject.enterprise.soap.sforce.com
<http://sobject.enterprise.soap.sforce.com/>"
>     xmlns:soap="http://www.w3.org/2003/05/soap-envelope/
<http://www.w3.org/2003/05/soap-envelope/>"
>     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance
<http://www.w3.org/2001/XMLSchema-instance>">
> <xsl:template match="soap:records[@xsi:type eq 'sf:CaseNote_GCC__c']">
> ...
> or
> <xsl:stylesheet version="2.0"
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform
<http://www.w3.org/1999/XSL/Transform>"
>     xmlns:sf="urn:sobject.enterprise.soap.sforce.com
<http://sobject.enterprise.soap.sforce.com/>"
>     xpath-default-namespace="http://www.w3.org/2003/05/soap-envelope/
<http://www.w3.org/2003/05/soap-envelope/>"
>     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance
<http://www.w3.org/2001/XMLSchema-instance>">
> ...
> should do the trick.
>
> 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
<http://www.w3.org/1999/XSL/Transform>"
>     xmlns:sf="urn:sobject.enterprise.soap.sforce.com
<http://sobject.enterprise.soap.sforce.com/>"
>     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance
<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.
>
>
> XSL-List info and archive <http://www.mulberrytech.com/xsl/xsl-list>
> EasyUnsubscribe <http://lists.mulberrytech.com/unsub/xsl-list/649132> (by
email)
> XSL-List info and archive <http://www.mulberrytech.com/xsl/xsl-list>
> EasyUnsubscribe <http://lists.mulberrytech.com/unsub/xsl-list/3514465> (by
email <applewebdata://E61E3DD9-457A-4BF1-ADC0-A23C559A6B06>)
> XSL-List info and archive <http://www.mulberrytech.com/xsl/xsl-list>
> EasyUnsubscribe <http://lists.mulberrytech.com/unsub/xsl-list/3500899> (by
email <>)

Current Thread