Altova Mailing List Archives>Archive Index >microsoft.public.xsl Archive Home >Recent entries [Thread Prev] >Thread Next - Re: xsl, dynamic lookup table / cross reference? xsl, dynamic lookup table / cross reference?To: NULL Date: 3/18/2009 1:19:00 PM ok, I have no idea if I am going to explain this in a logical manor...
The xsd wants an integer for contact id "1", the xml has an
alphanumeric "Contact1".
These values are defined first then referenced later in the xml.
So I need to temporarily store the lookup/cross reference.
For example:
This order item is for contact1 so in the transformation I need to
know that I had previously defined contact1 as 1.
/PrintTalk/Request/PurchaseOrder/jdf:JDF/ResourcePool/DeliveryIntent/
DropIntent/ContactRef/@rRef
XML:
<?xml version="1.0" encoding="UTF-8"?>
<PrintTalk xmlns="http://www.printtalk.org/schema" xmlns:jdf="http://
www.CIP4.org/JDFSchema_1_1" xmlns:xsi="http://www.w3.org/2001/
XMLSchema-instance" payloadID="2008-02-12T06:38:28-08:00.STANDARD-
P-145950" timeStamp="2008-02-12T06:38:28-08:00" version="1.1">
<Header>
<From>
<Credential domain="xyz.com">
<Identity>Xyz</Identity>
</Credential>
</From>
<To>
<Credential domain="prninter.com">
<Identity>ord...@prninter.com</Identity>
</Credential>
</To>
<Sender>
<Credential domain="xyz.com">
<Identity>Xyz</Identity>
<SharedSecret>XXXXXXXXX</SharedSecret>
</Credential>
<UserAgent>Xyz serve 1.9</UserAgent>
</Sender>
</Header>
<Request>
<PurchaseOrder AgentDisplayName="Xyz serve 1.3" AgentID="Xyz1.0"
BusinessID="XYZ-STR-350047" Currency="USD"
Expires="2008-05-21T12:08:25-07:00"
RequestDate="2008-02-21T11:08:25-08:00">
<jdf:JDF ID="JDF-Root" JobID="job-XYZ-STR-350047"
Status="Waiting" Type="Product-STANDARD">
<CustomerInfo CustomerID="Customer1">
<ContactRef rRef="Contact1"/>
</CustomerInfo>
<ResourceLinkPool>
<DeliveryIntentLink Usage="Input" rRef="Delivery1"/>
</ResourceLinkPool>
<ResourcePool>
<Contact Class="Parameter" ContactTypes="Billing"
ID="Contact1" Status="Available">
<Address City="Northpole" CountryCode="US"
ExtendedAddress="" PostalCode="99548" Region="AK" Street="156 Abby
Ave"/>
<Person FamilyName="" FirstName="Jane Doe">
<ComChannel ChannelType="Phone" Locator="5555551212"/>
<ComChannel ChannelType="Email" Locator=""/>
</Person>
</Contact>
<Contact Class="Parameter" ContactTypes="Shipping"
ID="Contact2" Status="Available">
<Address City="Northpole" CountryCode="US"
ExtendedAddress="" PostalCode="99548" Region="AK" Street="156 Abby
Ave"/>
<Person FamilyName="" FirstName="Jane Doe">
<ComChannel ChannelType="Phone" Locator="5555551212"/>
<ComChannel ChannelType="Email" Locator=""/>
</Person>
</Contact>
<DeliveryIntent Class="Intent" ID="Delivery1"
Status="Available">
<Method DataType="NameSpan" Preferred="UPS Ground"/>
<DropIntent>
<ContactRef rRef="Contact2"/>
<DropItemIntent Amount="1" Unit="ea">
<ComponentRef rRef="item-P-1234"/>
</DropItemIntent>
</DropIntent>
</DeliveryIntent>
</ResourcePool>
<JDF DescriptiveName="jacket-P-1234" ID="jdf-jacket-P-1234"
JobPartID="job-jacket-P-1234" Status="Waiting" Type="Product">
<ResourceLinkPool>
<ComponentLink rRef="jacket-P-1234"/>
<ColorIntentLink rRef="color-jacket-P-1234"/>
<MediaIntentLink rRef="media-jacket-P-1234"/>
<ArtDeliveryIntentLink rRef="art-jacket-P-1234"/>
</ResourceLinkPool>
<ResourcePool>
<Component Amount="1" Class="Quantity"
DescriptiveName="jacket-
P-1234" ID="jacket-P-1234" Status="Unavailable"/>
<ColorIntent Class="Intent" ID="color-jacket-P-1234"
Status="Available">
<ColorStandard DataType="NameSpan" Preferred="CMYK"/>
</ColorIntent>
<MediaIntent Class="Intent" ID="media-jacket-P-1234"
Status="Available">
<StockType DataType="NameSpan" Preferred="Bond">
<MediaColor DataType="EnumerationSpan"
Preferred="white"/>
<USWeight DataType="NumberSpan" Preferred="100"/>
<Grade DataType="IntegerSpan" Preferred="1"/>
</StockType>
</MediaIntent>
<ArtDeliveryIntent Class="Intent" ID="art-jacket-P-1234"
Status="Available">
<ArtDelivery ArtDeliveryType="DigitalNetwork"/>
<RunList>
<LayoutElement>
<FileSpec FileSize="1478254" FileVersion="1"
URL="http://
serve.xyz.com/cache/P201201/hardcover.prninter/P201201_d.pdf"/>
</LayoutElement>
</RunList>
</ArtDeliveryIntent>
</ResourcePool>
</JDF>
<JDF DescriptiveName="text-P-1234" ID="jdf-text-P-1234"
JobPartID="job-text-P-1234" Status="Waiting" Type="Product">
<ResourceLinkPool>
<ComponentLink rRef="text-P-1234"/>
<ColorIntentLink rRef="color-text-P-1234"/>
<MediaIntentLink rRef="media-text-P-1234"/>
<ArtDeliveryIntentLink rRef="art-text-P-1234"/>
</ResourceLinkPool>
<ResourcePool>
<Component Amount="1" Class="Quantity"
DescriptiveName="text-P-1234" ID="text-P-1234" Status="Unavailable"/>
<ColorIntent Class="Intent" ID="color-text-P-1234"
Status="Available">
<ColorStandard DataType="NameSpan" Preferred="CMYK"/>
</ColorIntent>
<MediaIntent Class="Intent" ID="media-text-P-1234"
Status="Available">
<StockType DataType="NameSpan" Preferred="Bond">
<MediaColor DataType="EnumerationSpan"
Preferred="white"/>
<USWeight DataType="NumberSpan" Preferred="80"/>
<Grade DataType="IntegerSpan" Preferred="2"/>
</StockType>
</MediaIntent>
<ArtDeliveryIntent Class="Intent" ID="art-text-P-1234"
Status="Available">
<ArtDelivery ArtDeliveryType="DigitalNetwork"/>
<RunList>
<LayoutElement>
<FileSpec FileSize="65370566" FileVersion="1"
URL="http://serve.xyz.com/cache/P201201/hardcover.prninter/
P201201_t.pdf"/>
</LayoutElement>
</RunList>
</ArtDeliveryIntent>
</ResourcePool>
</JDF>
<JDF DescriptiveName="book-P-1234" ID="jdf-P-1234"
JobPartID="job-P-1234" Status="Waiting" Type="Product">
<ResourceLinkPool>
<ComponentLink Usage="Output" rRef="item-P-1234"/>
<ComponentLink Usage="Input" rRef="jacket-P-1234"/>
<ComponentLink Usage="Input" rRef="text-P-1234"/>
<BindingIntentLink rRef="bind-P-1234"/>
<SizeIntentLink rRef="size-P-1234"/>
</ResourceLinkPool>
<ResourcePool>
<Component Amount="1" Class="Quantity"
DescriptiveName="the car book" ID="item-P-1234" Status="Unavailable"/>
<BindingIntent BindingOrder="Collecting" Class="Intent"
ID="bind-P-1234" Status="Available">
<BindingType DataType="EnumerationSpan" Preferred="7x7-
hardcover"/>
<HardCoverBinding>
<Jacket DataType="EnumerationSpan" Preferred="Loose"/>
</HardCoverBinding>
<SpineWidth/>
</BindingIntent>
<SizeIntent Class="Intent" ID="size-P-1234"
Status="Available">
<Dimensions DataType="NumberSpan" Preferred="495 477"
Range="485 467~505 487"/>
<Pages DataType="IntegerSpan" Preferred="60"/>
</SizeIntent>
</ResourcePool>
</JDF>
</jdf:JDF>
</PurchaseOrder>
</Request>
</PrintTalk>
XSL:
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/
Transform" xmlns:fn="http://www.w3.org/2005/02/xpath-functions"
xmlns:jdf="http://www.CIP4.org/JDFSchema_1_1" xmlns:pt="http://
www.printtalk.org/schema" exclude-result-prefixes="pt">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/
>
<xsl:template match="/">
<Order xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<xsl:attribute name="orderDate"><xsl:value-of
select="pt:PrintTalk/@timeStamp"/></xsl:attribute>
<xsl:attribute name="OrderID"><xsl:value-of select="pt:PrintTalk/
pt:Request/pt:PurchaseOrder/@BusinessID"/></xsl:attribute>
<xsl:attribute name="CustomerID"><xsl:value-of
select="pt:PrintTalk/pt:Header/pt:From/pt:Credential/pt:Identity"/></
xsl:attribute>
<xsl:for-each select="pt:PrintTalk/pt:Request/pt:PurchaseOrder/
jdf:JDF/pt:ResourcePool/pt:Contact">
<xsl:element name="Address">
<xsl:attribute name="AddressID"><xsl:value-of
select="position()"/></xsl:attribute>
<!--xsl:attribute name="AddressID"><xsl:value-of select="./
@ID"/></xsl:attribute-->
<firstname>
<xsl:value-of select="./pt:Person/@FirstName"/>
</firstname>
<lastname>
<xsl:value-of select="./pt:Person/@FamilyName"/>
</lastname>
<address1>
<xsl:value-of select="./pt:Address/@Street"/>
</address1>
<address2>
<xsl:value-of select="./pt:Address/@ExtendedAddress"/>
</address2>
<address3> </address3>
<city>
<xsl:value-of select="./pt:Address/@City"/>
</city>
<state>
<xsl:value-of select="./pt:Address/@Region"/>
</state>
<postalcode>
<xsl:value-of select="./pt:Address/@PostalCode"/>
</postalcode>
<xsl:choose>
<xsl:when test="string-length(./pt:Address/@CountryCode)
>0">
<country>
<xsl:value-of select="./pt:Address/@CountryCode"/>
</country>
</xsl:when>
<xsl:otherwise>
<country>US</country>
</xsl:otherwise>
</xsl:choose>
<phone>
<xsl:value-of select="./pt:Person/pt:ComChannel
[@ChannelType='Phone']/@Locator"/>
</phone>
<email>
<xsl:value-of select="./pt:Person/pt:ComChannel
[@ChannelType='Email']/@Locator"/>
</email>
</xsl:element>
</xsl:for-each>
<xsl:for-each select="pt:PrintTalk/pt:Request/pt:PurchaseOrder/
jdf:JDF/pt:ResourcePool/pt:Contact">
<Contact>
<xsl:attribute name="AddressID"><xsl:value-of
select="position()"/></xsl:attribute>
<xsl:attribute name="ContactID"><xsl:value-of
select="position()"/></xsl:attribute>
</Contact>
</xsl:for-each>
<ShipTo>
<ShipMethod>
<xsl:value-of select="pt:PrintTalk/pt:Request/
pt:PurchaseOrder/jdf:JDF/pt:ResourcePool/pt:DeliveryIntent/pt:Method/
@Preferred"/>
</ShipMethod>
</ShipTo>
<xsl:for-each select="pt:PrintTalk/pt:Request/pt:PurchaseOrder/
jdf:JDF/pt:ResourcePool/pt:DeliveryIntent/pt:DropIntent">
<CartItem>
<xsl:attribute name="ContactID"><xsl:value-of select="./
pt:ContactRef/@rRef"/></xsl:attribute>
</CartItem>
</xsl:for-each>
</Order>
</xsl:template>
</xsl:stylesheet>
Output:
<?xml version="1.0" encoding="UTF-8"?>
<Order orderDate="2008-02-12T06:38:28-08:00" OrderID="XYZ-STR-350047"
CustomerID="Xyz" xmlns:fn="http://www.w3.org/2005/02/xpath-functions"
xmlns:jdf="http://www.CIP4.org/JDFSchema_1_1" xmlns:xsi="http://
www.w3.org/2001/XMLSchema-instance">
<Address AddressID="1">
<firstname>Jane Doe</firstname>
<lastname />
<address1>156 Abby Ave</address1>
<address2 />
<address3 />
<city>Northpole</city>
<state>AK</state>
<postalcode>99548</postalcode>
<country>US</country>
<phone>5555551212</phone>
<email />
</Address>
<Address AddressID="2">
<firstname>Jane Doe</firstname>
<lastname />
<address1>156 Abby Ave</address1>
<address2 />
<address3 />
<city>Northpole</city>
<state>AK</state>
<postalcode>99548</postalcode>
<country>US</country>
<phone>5555551212</phone>
<email />
</Address>
<Contact AddressID="1" ContactID="1" />
<Contact AddressID="2" ContactID="2" />
<ShipTo>
<ShipMethod>UPS Ground</ShipMethod>
</ShipTo>
<CartItem ContactID="Contact2" />
</Order>
My cartitem contactid needs to be 2.
Thanks for any help and hope you understand my issue...
~Gina_M~
| ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
