XML Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreXML Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
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  
Old September 8th, 2003, 09:04 AM
JamesEdwar23 JamesEdwar23 is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Posts: 3 JamesEdwar23 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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:2000urchaseOrder:xdr:3.01" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:schemas-basda-org:2000urchaseOrder: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
Attached Files
File Type: xml purchaserecom.xml (2.0 KB, 201 views)

Reply With Quote
  #2  
Old September 8th, 2003, 04:25 PM
mmc mmc is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Posts: 2 mmc User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Please send the XSL you are working with

Reply With Quote
  #3  
Old September 9th, 2003, 03:17 AM
JamesEdwar23 JamesEdwar23 is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Posts: 3 JamesEdwar23 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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">
<xslutput 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>
Attached Files
File Type: txt recxslguil1a.txt (1.3 KB, 248 views)

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreXML Programming > Transforming XML TO XML using XSLT


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway