|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now! |
|
#1
|
|||
|
|||
|
Transforming XML TO XML using XSLT
I'm new to using XML and XSLT. I m trying to convert one xml doc into another one so just the relevant information is available. The following is the format that I want the xml doc to end up like:
- <Element> - <PurchaseElement> <Ship_Date>03.26.03</Ship_Date> <Pur_Order_No>P1130351</Pur_Order_No> <Customer_Code>181,053</Customer_Code> <Delivery_Date>03.27.03</Delivery_Date> <Quantity>190</Quantity> </PurchaseElement> The next bit of xml is the document in its current format. I apologise is this is quite long: <?xml version="1.0" encoding="utf-8"?> <Element> <Order xmlns="urn:schemas-basda-org:2000 urchaseOrder:xdr:3.01" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:schemas-basda-org:2000 urchaseOrder:xdr:3.01 URL"/><OrderHead> <Schema> <Version></Version> </Schema> <Parameters> <Language></Language> <DecimalSeparator></DecimalSeparator> <Precision></Precision> </Parameters> <OrderType Code="BLO"/> <OrderCurrency> <Currency Code="GBP"></Currency> </OrderCurrency> <Checksum/> </OrderHead> <OrderReferences> <ContractOrderReference> <PurchaseElement Customer_Code="181,053"/> </ContractOrderReference> <BuyersOrderNumber Preserve="true"/> <SuppliersOrderReference Preserve="true"> <PurchaseElement Purchase_Order_Number="P1130351"/> </SuppliersOrderReference> </OrderReferences> <OrderDate/> <Delivery> <PreferredDate> <PurchaseElement Delivery_Date="03.27.03"/> </PreferredDate> <SpecialInstructions> <PurchaseElement Ship_Date="03.26.03"/> </SpecialInstructions> </Delivery> <OrderLine TypeCode="GDS" Action="Add" TypeDescription="Goods & Services"> <LineNumber Preserve="true"/> <OrderLineReferences> <ContractOrderReference/> <CostCentre/> </OrderLineReferences> <Amount> <PurchaseElement Quantity="190"/> </Amount> <Price UOMCode="PCK" UOMDescription="Pack"> <Units/> <UnitPrice/> </Price> <LineTotal/> <Delivery> <PreferredDate/> </Delivery> <Narrative/> </OrderLine> </Element> I would be very grateful if anyone could help me. I have used xslt and I can grab the information but it is not in the format as the top example. If the above info is unclear I have attached the files also. Regards, James James |
|
#2
|
|||
|
|||
|
Please send the XSL you are working with
|
|
#3
|
|||
|
|||
|
Transforming XML TO XML using XSLT
Okay, the xsl that I am working with at the moment is attached to this document. Alternatively here is is below: Thanks, James
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl utput method="xml" indent="yes" encoding="utf-8" omit-xml-declaration="no"/><xsl:template match="/"> <Element> <xsl:apply-templates/> </Element> </xsl:template> <xsl:template match="Delivery/SpecialInstructions/PurchaseElement"> <PurchaseElement> <Ship_Date><xsl:apply-templates select="@*"/></Ship_Date> </PurchaseElement> </xsl:template> <xsl:template match="OrderReferences/SuppliersOrderReference/PurchaseElement"> <PurchaseElement> <Purchase_Order_Number><xsl:apply-templates select="@*"/></Purchase_Order_Number> </PurchaseElement> </xsl:template> <xsl:template match="OrderReferences/ContractOrderReference/PurchaseElement"> <PurchaseElement> <Customer_Code><xsl:apply-templates select="@*"/></Customer_Code> </PurchaseElement> </xsl:template> <xsl:template match="Delivery/PreferredDate/PurchaseElement"> <PurchaseElement> <Delivery_Date><xsl:apply-templates select="@*"/></Delivery_Date> </PurchaseElement> </xsl:template> <xsl:template match="OrderLine/Quantity/Amount/PurchaseElement"> <PurchaseElement> <Quantity><xsl:apply-templates select="@*"/></Quantity> </PurchaseElement> </xsl:template> </xsl:stylesheet> |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > XML Programming > Transforming XML TO XML using XSLT |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|