|
Subject: [xsl] total newbie From: Bill Smith <bfaith1us@xxxxxxxxx> Date: Thu, 11 Jun 2009 11:28:21 -0700 (PDT) |
Hello
I am very new to xml and xsl. I have what is probably the simplist of
simple. I have a xml file sent to me from a customer. When I open it in
excel it gives me a at least 1 line for every PO or more lines if there are 2
or more PO lines. So If there are 5 POs and 2 of those have 3 PO lines, excel
will show 9 records. I need fields from the POHeader, POLIne, and ShipTo
sections. Where there is more than 1 POLine, any header or ship to info I
have is just repeated in those rows by excel, which is what I want. My
xsl code that I have messes up when I have a PO with more than 1 POLine.
It adds up the info from both lines and puts them in the same node. Here is
the xml. There are a ton more fields than I am showing. I just need a
handful of them.
<EntireOrder>
<PO>
<POHeader>
</SomeHeaderInfo1>
</SomeHeaderInfo2>
</POHeader>
<POLine>
<Line1>
</SomeLineInfo2>
</ShipTo>
</ShipInfo1>
</ShipTo>
</POLine>
<POLine>
<Line2>
</SomeLineInfo2>
<ShipTo>
</ShipInfo1>
</ShipTo>
</POLine>
</PO>
</EntireOrder>
My xsl:
<xsl:output method="xml"
indent="yes"/>
<xsl:template match="/">
<Orders>
<xsl:for-each
select="EntireOrder/PO">
<Order>
<ShipToCustomer><xsl:apply-templates
select="POLine/ShipTo/ShipInfo1"/></ShipToCustomer>
<Description><xsl:apply-templates
select="POLine/SomeLineInfo2"/></Description>
<Quantity><xsl:apply-templates
select="POLine/SomeOtherLineInfo"/></Quantity>
<Buyer><xsl:apply-templates
select="POHeader/SomeHeaderInfo1"/></Buyer>
<Phone><xsl:apply-templates
select="POHeader/SomeHeaderInfo2"/></Phone>
<UnitPrice><xsl:apply-templates
select="POLine/SomeLineInfo3"/></UnitPrice>
<Total><xsl:apply-templates
select="POLine/SomeLineInfo4"/></Total>
</Order>
</xsl:for-each>
</Orders>
</xsl:template>
Again, if I have say 2 lines on a PO, I will
get 1 line for the PO but say the Buyer element will have both lines in the
same element. Heres what I get when there are more than 1 line. Notice all
the elements coming from POLine just double up the data. I would like 2
different <Order> records.
<Order>
<ShipToCustomer>Walmart</ShipToCustomer
<Description>TagsTags</Description>
<Quantity>100100>
<Buyer>Steve</Buyer>
<phone>555-5555</phone>
<UnitPrice>1010</UnitPrice>
<Total>10001000</Total>
</Order>
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| Re: [xsl] Center string, Michael Ludwig | Thread | Re: [xsl] total newbie, Sam Byland |
| Re: [xsl] Center string, Michael Ludwig | Date | Re: [xsl] total newbie, Sam Byland |
| Month |