Subject: Re: [xsl] Exclude child node details if child node is not in the xml file From: "Martin Honnen martin.honnen@xxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> Date: Sat, 28 Oct 2023 08:59:26 -0000 |
On 27/10/2023 21:37, LEGAULT, PHILLIP 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 > B 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/" > > xmlns="urn:enterprise.soap.sforce.com" > > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" > > xmlns:sf="urn:sobject.enterprise.soap.sforce.com" > > B B B B B B B B xsi:type="sf:Case"> > > B B <sf:Id>H</sf:Id> > > <sf:CaseNumber>004191992</sf:CaseNumber> > > <sf:Clone_OriginalRecord_GCC__c>5000D00000CIMezQAH</sf:Clone_OriginalRecord_G CC__c> > > B B <sf:Clone_OriginalRecord_GCC__r xsi:type="sf:Case"> > > B B B B B <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> > > B B <sf:Clone_ParentRecord_GCC__r xsi:type="sf:Case"> > > B B B B B <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:NoFurtherContactInfor mationProvided_GCC__c> > > <sf:Origin>Email</sf:Origin> > > B B <sf:Product_GCC__r xsi:type="sf:ProductLocal_GCC__c"> > > B B B B B <sf:Id xsi:nil="true"/> > > <sf:ArticleNumber_GCC__c>2</sf:ArticleNumber_GCC__c> > > B B B B B <sf:Locale_GCC__r xsi:type="sf:Locale_GCC__c"> > > B B B B B B B B <sf:Id xsi:nil="true"/> > > <sf:Region_GCC__c>NA</sf:Region_GCC__c> > > <sf:TranslationRequired_GCC__c>false</sf:TranslationRequired_GCC__c> > > B B B B B </sf:Locale_GCC__r> > > <sf:MarketStatus_GCC__c>ACTIVE</sf:MarketStatus_GCC__c> > > B B B B B <sf:Master_GCC__r xsi:type="sf:ProductMaster_GCC__c"> > > B B B B B B B B <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> > > B B B B B </sf:Master_GCC__r> > > <sf:Name>0045060341USA_en-us</sf:Name> > > <sf:RegulatoryStatus_GCC__c>OTC</sf:RegulatoryStatus_GCC__c> > > B B </sf:Product_GCC__r> > > <sf:Quantity_GCC__c>1.0</sf:Quantity_GCC__c> > > <sf:RelatedCases_GCC__c>8,2</sf:RelatedCases_GCC__c> > > B B <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. B <xsl:if test="/records/sf:RelatedCases_GCC__c"> should do, assuming you bind the right namespace to the prefix "sf" and use B B 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.
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] Exclude child node details if, LEGAULT, PHILLIP ple | Thread | Re: [xsl] Exclude child node detail, LEGAULT, PHILLIP ple |
[xsl] Exclude child node details if, LEGAULT, PHILLIP ple | Date | Re: [xsl] Exclude child node detail, LEGAULT, PHILLIP ple |
Month |