XML Editor
Sign up for a WebBoard account Sign Up Keyword Search Search More Options... Options
Chat Rooms Chat Help Help News News Log in to WebBoard Log in Not Logged in
Show tree view Topic
Topic Page 1 2 3 4 5 6 7 8 9 Go to previous topicPrev TopicGo to next topicNext Topic
Postnext
Rick ScofieldSubject: Adding values with document() lookup
Author: Rick Scofield
Date: 07 Oct 2006 05:37 PM
This forum is the best reason to use SS, so here is my question. I have a source file with product quantities and I want to lookup that product in another xml file to add the lookup quantity to the source quantity. So if the <upc> string in the source file matches the <upc> in the lookup file, then add <qtyavail> to <qty> otherwise use the <qtyavail>..I have also attached my current XSLT file.

Source file example:
<row>
<season>A</season>
<style>A02</style>
<color>BLK</color>
<siz>OFA</siz>
<upc>035481321559</upc>
<qtyavail>0002233</qtyavail>
<datavail>20061014</datavail>
</row>
<row>
<season>A</season>
<style>A02</style>
<color>BRN</color>
<siz>OFA</siz>
<upc>035481321566</upc>
<qtyavail>0002648</qtyavail>
<datavail>20061216</datavail>
</row>
Lookup file example:
<row>
<upc>035481321559</upc>
<qty>0000025</qty>
</row>
<row>
<upc>035481321566</upc>
<qty>0000015</qty>
</row>

Thank you for any help!


UnknownBODcc.xsl
XSL file

Postnext
Minollo I.Subject: Adding values with document() lookup
Author: Minollo I.
Date: 07 Oct 2006 08:38 PM
Just change:
<xsl:value-of select="qtyavail"/>
...into...
<xsl:variable name="upc" select="upc"/>
<xsl:value-of select="qtyavail + $Lookup//row[upc=$upc]/qty"/>

Postnext
Rick ScofieldSubject: Adding values with document() lookup
Author: Rick Scofield
Date: 08 Oct 2006 03:02 PM
Thank you Minola for the prompt reply. Your example worked great!, however my lookup xml file is around 30,000 lines...so the lookup takes bery long to complete. Is there a way to use the xsl:key on the lookup to sped things up, or maybe you have another suggestion.

Thanks,
Rick

Postnext
Ivan PedruzziSubject: Adding values with document() lookup
Author: Ivan Pedruzzi
Date: 08 Oct 2006 10:32 PM

Rick

you can use the xsl:key but remember to change context using a for-each to the auxiliary file when using the key function.

You didn't show us the lookup file UpcQty.xml so I made up one

See attached solution

Ivan Pedruzzi
Stylus Studio Team


DocumentBODcc(1).xsl


UnknownUpcQty.xml

Postnext
Rick ScofieldSubject: Adding values with document() lookup
Author: Rick Scofield
Date: 09 Oct 2006 09:03 AM
Originally Posted: 09 Oct 2006 09:02 AM
Ivan,
Thank you for the help on speeding up the lookup process, dare I ask one more question please? If the upc number is not found in UpcQty.xml the I get 'NaN' as the qtyavail...what is this and how can I just use the qtyvail in the source if the upc number is not found. I have attached a sample of my UpcQTy.xml file.

Thank you,
Rick


UnknownUpcQty(1).xml

Postnext
Ivan PedruzziSubject: Adding values with document() lookup
Author: Ivan Pedruzzi
Date: 09 Oct 2006 09:23 AM
Wrap the variable body with xsl:choose


Ivan Pedruzzi
Stylus Studio Team


UnknownBODcc(2).xsl

Posttop
Rick ScofieldSubject: Adding values with document() lookup
Author: Rick Scofield
Date: 10 Oct 2006 12:17 PM
Thank you Ivan, I used the following and seems to work!
<xsl:choose>
<xsl:when test="$rproqty &gt; 1">
<xsl:value-of select="qtyavail + $rproqty"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="qtyavail"/>
</xsl:otherwise>
</xsl:choose>

Thank you again!
Rick

 
Topic Page 1 2 3 4 5 6 7 8 9 Go to previous topicPrev TopicGo to next topicNext Topic
Download A Free Trial of Stylus Studio 6 XML Professional Edition Today! Powered by Stylus Studio, the world's leading XML IDE for XML, XSLT, XQuery, XML Schema, DTD, XPath, WSDL, XHTML, SQL/XML, and XML Mapping!  
go

Log In Options

Site Map | Privacy Policy | Terms of Use | Trademarks
Stylus Scoop XML Newsletter:
W3C Member
Stylus Studio® and DataDirect XQuery ™are from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2016 All Rights Reserved.