Jump to content
Sign in to follow this  
simonhi99

XSLT to Extract XML from SOAP message

Recommended Posts

I have used XSLT for a number of years but have never come across a SOAP wrapped XML file. I need to modify the XML message using the XSLT below to extract certain elements into a new XML file. I have declared the namespaces but no matter how I set up the xsl:template match, I cannot seem to reference anything under the Batch element. Can anyone point me in the right direction please. Thanks,Simon <?xml version="1.0" encoding="UTF-8" ?><xsl:stylesheet version="1.0"xmlns:xsl="http://www.w3.org/1999/XSL/Transform"xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"xmlns:b="urn:schemas-basda-org:BatchEnvelope"> <xsl:output method="XML" encoding="UTF-8" omit-xml-declaration="yes" indent="yes"/> <xsl:variable name="newline"><xsl:text></xsl:text></xsl:variable> <!-- *******************************************************************************--><xsl:template match="/"><xsl:apply-templates select="d:Batch"/></xsl:template> <xsl:template match="/b:Batch"> <Batch><xsl:for-each select="Invoice"> <Invoice> <InvoiceHead> <xsl:copy-of select="InvoiceHead/InvoiceType"/> </InvoiceHead> <xsl:copy-of select="TaxPointDate"/>...... Cut down XML: <?xml version="1.0" encoding="UTF-8" standalone="no"?><SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"> <SOAP-ENV:header> <div:delivery xmlns:div="http://schemas.biztalk.org/btf-2-0/delivery" SOAP-ENV:mustUnderstand="1"> <div:message> <div:messageID></div:messageID> </div:message> <div:to> <div:address></div:address> </div:to> <div:from> <div:address></div:address> </div:from> </div:delivery> <prop:properties xmlns:prop="http://schemas.biztalk.org/btf-2-0/properties" SOAP-ENV:mustUnderstand="1"> <prop:identity>00000000</prop:identity> <prop:sentAt>2012-06-27T20:00:57</prop:sentAt> <prop:expiresAt>2010-01-01T00:00:00</prop:expiresAt> <prop:topic>BBAINV</prop:topic> </prop:properties> </SOAP-ENV:header> <SOAP-ENV:body> <Batch xmlns="urn:schemas-basda-org:BatchEnvelope" DocType="Invoice" SupplierName="76787980" Number="2" Date="2012-06-27"> <Invoice> <InvoiceHead> <Schema> <Version>3.09</Version> </Schema> <Stylesheet> <StylesheetOwner>BASDA</StylesheetOwner> <StylesheetName>eBIS-XML_simple.xsl</StylesheetName> <Version>1</Version> <StylesheetType>XSL</StylesheetType> <LogoURL>http://www.someone.co.uk/stylesheets/invoices.xsl</LogoURL> </Stylesheet> <Parameters> <Language>en-GB</Language> <DecimalSeparator>.</DecimalSeparator> <Precision>20.4</Precision> </Parameters> <OriginatingSoftware> <SoftwareManufacturer></SoftwareManufacturer> <SoftwareProduct></SoftwareProduct> <SoftwareVersion></SoftwareVersion> <SoftwareSystemID></SoftwareSystemID> </OriginatingSoftware> <TestFlag TestReference=""> <Test ExpectedReply="" Mode=""></Test> </TestFlag> <InvoiceType Code="INV" Codelist="99">INVOICE</InvoiceType> <Function Code="" Codelist="" Preserve=""></Function> <InvoiceCurrency> <Currency Code="GBP" Codelist="">GBP</Currency> <AlternateCurrency Code="" Codelist=""></AlternateCurrency> <Rate CalculationType=""></Rate> </InvoiceCurrency> <Intrastat> <CommodityCode></CommodityCode> <CommodityDescription></CommodityDescription> <NatureOfTransaction Code="" Codelist=""></NatureOfTransaction> <SupplementaryUnits></SupplementaryUnits> <CountryOfDestination Code="" Codelist=""></CountryOfDestination> <ModeOfTransport Code="" Codelist=""></ModeOfTransport> </Intrastat> <Checksum></Checksum> </InvoiceHead> <InvoiceReferences> <ContractOrderReference>1499001</ContractOrderReference> <CostCentre>999925/1</CostCentre> <BuyersOrderNumber Preserve="">22111366</BuyersOrderNumber> <Department></Department> <GeneralLedgerCode></GeneralLedgerCode> <ProjectCode Preserve="true">SH146597</ProjectCode> <ProjectAnalysisCode Preserve="true">101999</ProjectAnalysisCode> <SuppliersInvoiceNumber Preserve="true">10011999</SuppliersInvoiceNumber> <DeliveryNoteNumber>SH 22925/1</DeliveryNoteNumber> <SuppliersOrderReference Preserve="">SH 111925</SuppliersOrderReference> <ResponseTo></ResponseTo> <BatchNumber></BatchNumber> <GloballyUniqueID Preserve=""></GloballyUniqueID> </InvoiceReferences> ......

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...