[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: total newbie

Subject: Re: total newbie
From: Bill Smith <bfaith1us@xxxxxxxxx>
Date: Fri, 12 Jun 2009 06:22:23 -0700 (PDT)
Re:  total newbie
Excellent!  Thanks!  I was trying to shorten it up a bit since it seemed like
my post was getting really long.  I guess I know less than I thought I did. 
Thanks again.



----- Original Message ----
From: Sam Byland
<shbyland@xxxxxxxxxxx>
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Sent: Thursday,
June 11, 2009 2:12:23 PM
Subject: Re:  total newbie

Bill,

It will make
it easier on us if your sample XML is well formed, and contains the content
that results in your sample output.  The XML you provided isn't well formed,
and doesn't contain the text values you are showing in your sample output.
Guessing as to what was in your sample input XML that results in your output,
I am thinking you had something like this:

<EntireOrder>
  <PO>
   
<POHeader>
        <SomeHeaderInfo1>Steve</SomeHeaderInfo1>
       
<SomeHeaderInfo2>555-5555</SomeHeaderInfo2>
    </POHeader>
    <POLine>
     
  <SomeOtherLineInfo>100</SomeOtherLineInfo>
       
<SomeLineInfo2>Tags</SomeLineInfo2>
        <SomeLineInfo3>10</SomeLineInfo3>
        <SomeLineInfo4>1000</SomeLineInfo4>
        <ShipTo>
         
<ShipInfo1>Walmart</ShipInfo1>
        </ShipTo>
    </POLine>
    <POLine>
 
      <SomeOtherLineInfo>100</SomeOtherLineInfo>
       
<SomeLineInfo2>Tags</SomeLineInfo2>
        <SomeLineInfo3>10</SomeLineInfo3>
        <SomeLineInfo4>1000</SomeLineInfo4>
        <ShipTo>
         
<ShipInfo1>Walmart</ShipInfo1>
        </ShipTo>
    </POLine>
  </PO>
</EntireOrder>

However, I would then expect you to have "Walmart" appearing
twice in your output, and in your post it appears only once....

That aside,
this might do what you're looking for:

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

  <xsl:output method="xml"
indent="yes"/>

  <xsl:template match="/">

    <Orders>

       
<xsl:for-each select="EntireOrder/PO/POLine">
          <Order>
             
<ShipToCustomer>
                <xsl:apply-templates
select="ShipTo/ShipInfo1"/>
              </ShipToCustomer>
             
<Description>
                <xsl:apply-templates select="SomeLineInfo2"/>
 
            </Description>
              <Quantity>
               
<xsl:apply-templates select="SomeOtherLineInfo"/>
              </Quantity>
 
            <Buyer>
                <xsl:apply-templates
select="../POHeader/SomeHeaderInfo1"/>
              </Buyer>
             
<Phone>
                <xsl:apply-templates
select="../POHeader/SomeHeaderInfo2"/>
              </Phone>
             
<UnitPrice>
                <xsl:apply-templates select="SomeLineInfo3"/>
   
          </UnitPrice>
              <Total>
               
<xsl:apply-templates select="SomeLineInfo4"/>
              </Total>
         
</Order>
        </xsl:for-each>

    </Orders>

  </xsl:template>
</xsl:stylesheet>

The above stylesheet applied to the corrected XML I pasted
above yields:

<Orders>
  <Order>
    <ShipToCustomer>Walmart</ShipToCustomer>
    <Description>Tags</Description>
    <Quantity>100</Quantity>
   
<Buyer>Steve</Buyer>
    <Phone>555-5555</Phone>
    <UnitPrice>10</UnitPrice>
    <Total>1000</Total>
  </Order>
  <Order>
   
<ShipToCustomer>Walmart</ShipToCustomer>
    <Description>Tags</Description>
 
  <Quantity>100</Quantity>
    <Buyer>Steve</Buyer>
   
<Phone>555-5555</Phone>
    <UnitPrice>10</UnitPrice>
    <Total>1000</Total>
  </Order>
</Orders>

Hope that helps,

...sam

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.