[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Exclude child node details if child node is not in

Subject: Re: Exclude child node details if child node is not in the xml file
From: "LEGAULT, PHILLIP plegault@xxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Mon, 30 Oct 2023 10:45:57 -0000
Re:  Exclude child node details if child node is not in
OK I figured it out anyway

From: Martin Honnen martin.honnen@xxxxxx
<xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Sent: Saturday, October 28, 2023 5:00 AM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: [EXTERNAL] Re:  Exclude child node details if child node is not
in the xml file



On 27/10/2023 21:37, LEGAULT, PHILLIP
plegault@xxxxxxxxxx<mailto:plegault@xxxxxxxxxx> wrote:
I have a soap xml file Ibm downloading and transforming using saxon xslt 2 ,
the file may or may not include child node  bRelatedCases_GCC__cb, If not
do not add empty tags. If so then add tags with resulting text. Xslt example
below xml details that fails.

====================XML file===========================
<?xml version="1.0" encoding="UTF-8"?>
<records
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"<http://schemas.xmls
oap.org/soap/envelope/>
         xmlns="urn:enterprise.soap.sforce.com"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"<http://www.w3.
org/2001/XMLSchema-instance>
         xmlns:sf="urn:sobject.enterprise.soap.sforce.com"
         xsi:type="sf:Case">
   <sf:Id>H</sf:Id>
   <sf:CaseNumber>004191992</sf:CaseNumber>
   <sf:Clone_OriginalRecord_GCC__c>5000D00000CIMezQAH</sf:Clone_OriginalRecor
d_GCC__c>
   <sf:Clone_OriginalRecord_GCC__r xsi:type="sf:Case">
      <sf:Id xsi:nil="true"/>
      <sf:CaseNumber>8</sf:CaseNumber>
   </sf:Clone_OriginalRecord_GCC__r>
   <sf:Clone_ParentRecord_GCC__c>H</sf:Clone_ParentRecord_GCC__c>
   <sf:Clone_ParentRecord_GCC__r xsi:type="sf:Case">
      <sf:Id xsi:nil="true"/>
      <sf:CaseNumber>8</sf:CaseNumber>
   </sf:Clone_ParentRecord_GCC__r>
   <sf:CountryMarketed_GCC__c>s</sf:CountryMarketed_GCC__c>
   <sf:DueDiligenceRequired_GCC__c>false</sf:DueDiligenceRequired_GCC__c>
   <sf:NoFurtherContactInformationProvided_GCC__c>true</sf:NoFurtherContactIn
formationProvided_GCC__c>
   <sf:Origin>Email</sf:Origin>
   <sf:Product_GCC__r xsi:type="sf:ProductLocal_GCC__c">
      <sf:Id xsi:nil="true"/>
      <sf:ArticleNumber_GCC__c>2</sf:ArticleNumber_GCC__c>
      <sf:Locale_GCC__r xsi:type="sf:Locale_GCC__c">
         <sf:Id xsi:nil="true"/>
         <sf:Region_GCC__c>NA</sf:Region_GCC__c>
         <sf:TranslationRequired_GCC__c>false</sf:TranslationRequired_GCC__c>
      </sf:Locale_GCC__r>
      <sf:MarketStatus_GCC__c>ACTIVE</sf:MarketStatus_GCC__c>
      <sf:Master_GCC__r xsi:type="sf:ProductMaster_GCC__c">
         <sf:Id xsi:nil="true"/>
         <sf:Description_GCC__c>Z</sf:Description_GCC__c>
         <sf:FormulaNumber_GCC__c>NotSpecified</sf:FormulaNumber_GCC__c>
         <sf:SameSimilar_GCC__c>Not Applicable</sf:SameSimilar_GCC__c>
      </sf:Master_GCC__r>
      <sf:Name>0045060341USA_en-us</sf:Name>
      <sf:RegulatoryStatus_GCC__c>OTC</sf:RegulatoryStatus_GCC__c>
   </sf:Product_GCC__r>
   <sf:Quantity_GCC__c>1.0</sf:Quantity_GCC__c>
   <sf:RelatedCases_GCC__c>8,2</sf:RelatedCases_GCC__c>
   <sf:Subject>Testing Final Scenario</sf:Subject>

</records>
========================================= end
XML==================================

I want to exclude these fields if  bRelated Cases does not exist.

<xsl:If "/records/sf:RelatedCases_GCC__c">
Original Case: <xsl:value-of
select="/records/sf:Clone_OriginalRecord_GCC__r/sf:CaseNumber"/>
Cloned From Case: <xsl:value-of select="/records/sf:CaseNumber"/>
Related Cases:<xsl:value-of select="/records/sf:RelatedCases_GCC__c"/>
</xsl:if>



Well, that looks like pseudo code, that is not even the right syntax. And of
course namespace declarations and context for the XSLT are missing. Therefore
it is not possible to tell where your attempt failed.

I also haven't quite understood whether you just want/need to check for the
pure existence of that sf:RelatedCases_GCC__c element or whether the numbers
listed in there need to be checked against one or some of the other elements.

If you only want to check there is such an element then e.g.

  <xsl:if test="/records/sf:RelatedCases_GCC__c">

should do, assuming you bind the right namespace to the prefix "sf" and use

   xpath-default-namespace="urn:enterprise.soap.sforce.com"

in the XSLT to ensure the /records part of the path selects the records
element in that namespace.
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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.