Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: position()

From: Gina_Marano <ginalster@-----.--->
To: NULL
Date: 3/30/2009 5:06:00 PM
On Mar 30, 4:35=A0pm, Gina_Marano <ginals...@gmail.com> wrote:
> On Mar 30, 4:20=A0pm, Gina_Marano <ginals...@gmail.com> wrote:
>
>
>
>
>
> > I am not quite sure how to get the information that I need.
>
> > I have read a lot of different newsgroups but don't understand how to
> > put the context in my xsl document.
>
> > What I need is to look up the position of the contactid in the
> > original xml.
>
> > XML:
>
> > <?xml version=3D"1.0" encoding=3D"UTF-8"?>
> > <Request>
> > =A0 <PurchaseOrder>
> > =A0 =A0 <JDFX>
> > =A0 =A0 =A0 <ResourcePool>
> > =A0 =A0 =A0 =A0 <Contact Class=3D"Parameter" ContactTypes=3D"Billing"
> > ID=3D"ContactA">
> > =A0 =A0 =A0 =A0 =A0 <Address City=3D"Millers" PostalCode=3D"09921" Regi=
on=3D"AK"
> > Street=3D"300 N George St"/>
> > =A0 =A0 =A0 =A0 =A0 <Person FamilyName=3D"" FirstName=3D"Jane Doe">
> > =A0 =A0 =A0 =A0 =A0 =A0 <ComChannel ChannelType=3D"Phone" Locator=3D"71=
7-917-9182"/>
> > =A0 =A0 =A0 =A0 =A0 =A0 <ComChannel ChannelType=3D"Email" Locator=3D""/=
>
> > =A0 =A0 =A0 =A0 =A0 </Person>
> > =A0 =A0 =A0 =A0 </Contact>
> > =A0 =A0 =A0 =A0 <Contact Class=3D"Parameter" ContactTypes=3D"Billing"
> > ID=3D"ContactB">
> > =A0 =A0 =A0 =A0 =A0 <Address City=3D"Millers" PostalCode=3D"09921" Regi=
on=3D"AK"
> > Street=3D"501 S Elm"/>
> > =A0 =A0 =A0 =A0 =A0 <Person FamilyName=3D"" FirstName=3D"Jim Smith">
> > =A0 =A0 =A0 =A0 =A0 =A0 <ComChannel ChannelType=3D"Phone" Locator=3D"71=
7-917-9182"/>
> > =A0 =A0 =A0 =A0 =A0 =A0 <ComChannel ChannelType=3D"Email" Locator=3D""/=
>
> > =A0 =A0 =A0 =A0 =A0 </Person>
> > =A0 =A0 =A0 =A0 </Contact>
> > =A0 =A0 =A0 =A0 <Contact Class=3D"Parameter" ContactTypes=3D"Billing"
> > ID=3D"ContactC">
> > =A0 =A0 =A0 =A0 =A0 <Address City=3D"Millers" PostalCode=3D"09921" Regi=
on=3D"AK"
> > Street=3D"800 SW Lincoln St"/>
> > =A0 =A0 =A0 =A0 =A0 <Person FamilyName=3D"" FirstName=3D"Uncle Joe">
> > =A0 =A0 =A0 =A0 =A0 =A0 <ComChannel ChannelType=3D"Phone" Locator=3D"71=
7-917-9182"/>
> > =A0 =A0 =A0 =A0 =A0 =A0 <ComChannel ChannelType=3D"Email" Locator=3D""/=
>
> > =A0 =A0 =A0 =A0 =A0 </Person>
> > =A0 =A0 =A0 =A0 </Contact>
> > =A0 =A0 =A0 =A0 <DeliveryIntent Class=3D"Intent" ID=3D"Delivery1"
> > Status=3D"Available">
> > =A0 =A0 =A0 =A0 =A0 <Method DataType=3D"NameSpan" Preferred=3D"UPS Grou=
nd"/>
> > =A0 =A0 =A0 =A0 =A0 <DropIntent>
> > =A0 =A0 =A0 =A0 =A0 =A0 <Required DataType=3D"TimeSpan"
> > Preferred=3D"2008-02-15T06:38:28-08:00"/>
> > =A0 =A0 =A0 =A0 =A0 =A0 <ContactRef rRef=3D"ContactA"/>
> > =A0 =A0 =A0 =A0 =A0 =A0 <DropItemIntent Amount=3D"10" Unit=3D"ea">
> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 <ComponentRef rRef=3D"I62235"/>
> > =A0 =A0 =A0 =A0 =A0 =A0 </DropItemIntent>
> > =A0 =A0 =A0 =A0 =A0 </DropIntent>
> > =A0 =A0 =A0 =A0 =A0 <DropIntent>
> > =A0 =A0 =A0 =A0 =A0 =A0 <Required DataType=3D"TimeSpan"
> > Preferred=3D"2008-02-15T06:38:28-08:00"/>
> > =A0 =A0 =A0 =A0 =A0 =A0 <ContactRef rRef=3D"ContactB"/>
> > =A0 =A0 =A0 =A0 =A0 =A0 <DropItemIntent Amount=3D"2" Unit=3D"ea">
> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 <ComponentRef rRef=3D"I62236"/>
> > =A0 =A0 =A0 =A0 =A0 =A0 </DropItemIntent>
> > =A0 =A0 =A0 =A0 =A0 </DropIntent>
> > =A0 =A0 =A0 =A0 =A0 <DropIntent>
> > =A0 =A0 =A0 =A0 =A0 =A0 <Required DataType=3D"TimeSpan"
> > Preferred=3D"2008-02-15T06:38:28-08:00"/>
> > =A0 =A0 =A0 =A0 =A0 =A0 <ContactRef rRef=3D"ContactC"/>
> > =A0 =A0 =A0 =A0 =A0 =A0 <DropItemIntent Amount=3D"1" Unit=3D"ea">
> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 <ComponentRef rRef=3D"I62236"/>
> > =A0 =A0 =A0 =A0 =A0 =A0 </DropItemIntent>
> > =A0 =A0 =A0 =A0 =A0 </DropIntent>
> > =A0 =A0 =A0 =A0 </DeliveryIntent>
> > =A0 =A0 =A0 </ResourcePool>
> > =A0 =A0 </JDFX>
> > =A0 </PurchaseOrder>
> > </Request>
>
> > XSL:
>
> > <?xml version=3D"1.0"?>
> > <xsl:stylesheet version=3D"1.0" xmlns:xsl=3D"http://www.w3.org/1999/XSL=
/
> > Transform">
> > =A0 <xsl:output method=3D"xml" version=3D"1.0" encoding=3D"UTF-8" inden=
t=3D"yes"/
>
> > =A0 <xsl:template match=3D"/">
> > =A0 =A0 <Order xmlns:xsi=3D"http://www.w3.org/2001/XMLSchema-instance">
> > =A0 =A0 =A0 <xsl:for-each select=3D"/Request/PurchaseOrder/JDFX/Resourc=
ePool/
> > Contact">
> > =A0 =A0 =A0 =A0 <xsl:element name=3D"Address">
> > =A0 =A0 =A0 =A0 =A0 <xsl:attribute name=3D"CustomerID"><xsl:value-of
> > select=3D"position()"/></xsl:attribute>
> > =A0 =A0 =A0 =A0 =A0 <firstname>
> > =A0 =A0 =A0 =A0 =A0 =A0 <xsl:value-of select=3D"./Person/@FirstName"/>
> > =A0 =A0 =A0 =A0 =A0 </firstname>
> > =A0 =A0 =A0 =A0 =A0 <lastname>
> > =A0 =A0 =A0 =A0 =A0 =A0 <xsl:value-of select=3D"./Person/@FamilyName"/>
> > =A0 =A0 =A0 =A0 =A0 </lastname>
> > =A0 =A0 =A0 =A0 =A0 <address1>
> > =A0 =A0 =A0 =A0 =A0 =A0 <xsl:value-of select=3D"./Address/@Street"/>
> > =A0 =A0 =A0 =A0 =A0 </address1>
> > =A0 =A0 =A0 =A0 =A0 <city>
> > =A0 =A0 =A0 =A0 =A0 =A0 <xsl:value-of select=3D"./Address/@City"/>
> > =A0 =A0 =A0 =A0 =A0 </city>
> > =A0 =A0 =A0 =A0 =A0 <state>
> > =A0 =A0 =A0 =A0 =A0 =A0 <xsl:value-of select=3D"./Address/@Region"/>
> > =A0 =A0 =A0 =A0 =A0 </state>
> > =A0 =A0 =A0 =A0 =A0 <postalcode>
> > =A0 =A0 =A0 =A0 =A0 =A0 <xsl:value-of select=3D"./Address/@PostalCode"/=
>
> > =A0 =A0 =A0 =A0 =A0 </postalcode>
> > =A0 =A0 =A0 =A0 =A0 <phone>
> > =A0 =A0 =A0 =A0 =A0 =A0 <xsl:value-of select=3D"./Person/ComChannel
> > [@ChannelType=3D'Phone']/@Locator"/>
> > =A0 =A0 =A0 =A0 =A0 </phone>
> > =A0 =A0 =A0 =A0 =A0 <email>
> > =A0 =A0 =A0 =A0 =A0 =A0 <xsl:value-of select=3D"./Person/ComChannel
> > [@ChannelType=3D'Email']/@Locator"/>
> > =A0 =A0 =A0 =A0 =A0 </email>
> > =A0 =A0 =A0 =A0 </xsl:element>
> > =A0 =A0 =A0 </xsl:for-each>
> > =A0 =A0 =A0 <xsl:for-each select=3D"PrintTalk/Request/PurchaseOrder/JDF=
X/
> > ResourcePool/Contact">
> > =A0 =A0 =A0 =A0 <Contact>
> > =A0 =A0 =A0 =A0 =A0 <xsl:attribute name=3D"AddressID"><xsl:value-of
> > select=3D"position()"/></xsl:attribute>
> > =A0 =A0 =A0 =A0 =A0 <xsl:attribute name=3D"ContactID"><xsl:value-of
> > select=3D"position()"/></xsl:attribute>
> > =A0 =A0 =A0 =A0 </Contact>
> > =A0 =A0 =A0 </xsl:for-each>
> > =A0 =A0 =A0 <ShipTo>
> > =A0 =A0 =A0 =A0 <ShipMethod>
> > =A0 =A0 =A0 =A0 =A0 <xsl:value-of select=3D"Request/PurchaseOrder/JDFX/
> > ResourcePool/DeliveryIntent/Method/@Preferred"/>
> > =A0 =A0 =A0 =A0 </ShipMethod>
> > =A0 =A0 =A0 </ShipTo>
> > =A0 =A0 =A0 <xsl:for-each select=3D"Request/PurchaseOrder/JDFX/Resource=
Pool/
> > DeliveryIntent/DropIntent">
> > =A0 =A0 =A0 =A0 <CartItem>
> > =A0 =A0 =A0 =A0 =A0 <xsl:attribute name=3D"CustomerID"><xsl:value-of se=
lect=3D"./
> > ContactRef/@rRef"/></xsl:attribute>
> > =A0 =A0 =A0 =A0 =A0 <xsl:attribute name=3D"CartItemID"><xsl:value-of
> > select=3D"position()"/></xsl:attribute>
> > =A0 =A0 =A0 =A0 =A0 <xsl:attribute name=3D"quantity"><xsl:value-of sele=
ct=3D"./
> > DropItemIntent/@Amount"/></xsl:attribute>
> > =A0 =A0 =A0 =A0 =A0 <ShipTo quantity=3D"1">
> > =A0 =A0 =A0 =A0 =A0 =A0 <xsl:attribute name=3D"CustomerID"><xsl:value-o=
f select=3D"./
> > ContactRef/@rRef"/></xsl:attribute>
> > =A0 =A0 =A0 =A0 =A0 =A0 <xsl:attribute name=3D"quantity"><xsl:value-of =
select=3D"./
> > DropItemIntent/@Amount"/></xsl:attribute>
> > =A0 =A0 =A0 =A0 =A0 </ShipTo>
> > =A0 =A0 =A0 =A0 </CartItem>
> > =A0 =A0 =A0 </xsl:for-each>
> > =A0 =A0 </Order>
> > =A0 </xsl:template>
> > </xsl:stylesheet>
>
> > Ouput:
>
> > <?xml version=3D"1.0" encoding=3D"UTF-8"?>
> > <Order xmlns:xsi=3D"http://www.w3.org/2001/XMLSchema-instance">
> > =A0 <Address CustomerID=3D"1">
> > =A0 =A0 <firstname>Jane Doe</firstname>
> > =A0 =A0 <lastname />
> > =A0 =A0 <address1>300 N George St</address1>
> > =A0 =A0 <city>Millers</city>
> > =A0 =A0 <state>AK</state>
> > =A0 =A0 <postalcode>09921</postalcode>
> > =A0 =A0 <phone>717-917-9182</phone>
> > =A0 =A0 <email />
> > =A0 </Address>
> > =A0 <Address CustomerID=3D"2">
> > =A0 =A0 <firstname>Jim Smith</firstname>
> > =A0 =A0 <lastname />
> > =A0 =A0 <address1>501 S Elm</address1>
> > =A0 =A0 <city>Millers</city>
> > =A0 =A0 <state>AK</state>
> > =A0 =A0 <postalcode>09921</postalcode>
> > =A0 =A0 <phone>717-917-9182</phone>
> > =A0 =A0 <email />
> > =A0 </Address>
> > =A0 <Address CustomerID=3D"3">
> > =A0 =A0 <firstname>Uncle Joe</firstname>
> > =A0 =A0 <lastname />
> > =A0 =A0 <address1>800 SW Lincoln St</address1>
> > =A0 =A0 <city>Millers</city>
> > =A0 =A0 <state>AK</state>
> > =A0 =A0 <postalcode>09921</postalcode>
> > =A0 =A0 <phone>717-917-9182</phone>
> > =A0 =A0 <email />
> > =A0 </Address>
> > =A0 <ShipTo>
> > =A0 =A0 <ShipMethod>UPS Ground</ShipMethod>
> > =A0 </ShipTo>
> > =A0 <CartItem CustomerID=3D"ContactA" CartItemID=3D"1" quantity=3D"10">
> > =A0 =A0 <ShipTo quantity=3D"10" CustomerID=3D"ContactA" />
> > =A0 </CartItem>
> > =A0 <CartItem CustomerID=3D"ContactB" CartItemID=3D"2" quantity=3D"2">
> > =A0 =A0 <ShipTo quantity=3D"2" CustomerID=3D"ContactB" />
> > =A0 </CartItem>
> > =A0 <CartItem CustomerID=3D"ContactC" CartItemID=3D"3" quantity=3D"1">
> > =A0 =A0 <ShipTo quantity=3D"1" CustomerID=3D"ContactC" />
> > =A0 </CartItem>
> > </Order>
>
> > In the output I actually want 1, 2 or 3 which would be the position()
> > of the Contact in the original XML.
> > =A0 <Contact Class=3D"Parameter" ContactTypes=3D"Billing" ID=3D"Contact=
A">
>
> > -->
>
> > =A0 <CartItem CustomerID=3D"ContactA" CartItemID=3D"1" quantity=3D"10">
> > =A0 =A0 <ShipTo quantity=3D"10" CustomerID=3D"1" />
> > =A0 </CartItem>
>
> > Thanks for any help
>
> > ~Gina_M~
>
> I tried:
>
> =A0 =A0 =A0 =A0 =A0 <xsl:attribute name=3D"CustomerID"><xsl:value-of sele=
ct=3D"/
> Request/PurchaseOrder/JDFX/ResourcePool/Contact[@ID=3D./ContactRef/
> @rRef]/position()"/></xsl:attribute>
>
> but it doesn't like "position".
>
> ~Gina_M~- Hide quoted text -
>
> - Show quoted text -

          <xsl:attribute name=3D"CustomerID"><xsl:value-of select=3D"count
(/Request/PurchaseOrder/JDFX/ResourcePool/Contact[@ID=3D$currContactRef]/
preceding-sibling::*)+1"/></xsl:attribute>

works. Will this always be the case? What does it actually mean?

~Gina_M~


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent