Jump to content

XSLT to Extract XML from SOAP message


simonhi99
 Share

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> ......

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...