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
Conferences Close Tree View
+ Stylus Studio Feature Requests (1192)
+ Stylus Studio Technical Forum (14621)
+ Website Feedback (249)
- XSLT Help and Discussion (7625)
-> + sort by variable (11)
-> + [XSLT Recursive Template Help]... (2)
-> - Adding values with document() ... (7)
-> ->Adding values with docume...
-> ->Adding values with docume...
-> ->Adding values with docume...
-> ->Adding values with docume...
-> ->Adding values with docume...
-> ->Adding values with docume...
-> + merging xml files in to single... (2)
-> + Limit description characters i... (2)
-> + problem parsing xml as text in... (2)
-> + Summarize/Distinct (5)
-> + unix epoch seconds to date str... (3)
-> + xml, xslt question (5)
-> + LGCL XSLT transformation (3)
-> + Dynamic include (3)
-> + .rdbxml as XML within Stylus ... (3)
-> + Array of Values From XSL (2)
-> + Problem Saving output (2)
-> + Base 64 encoded data embedded ... (2)
-> + XML-XML Mapping (2)
-> - Parameterized 'Document()' ...... (1)
-> + Newbie prob - Elements with sa... (3)
-> - .net 1.1 incorrectly processin... (1)
-> + xs:key and xs:keyref question (5)
-> + pass xsl-variable to javascrip... (2)
-- Previous [1321-1340] [1341-1360] [1361-1380] Next
+ XQuery Help and Discussion (2017)
+ Stylus Studio FAQs (159)
+ Stylus Studio Code Samples & Utilities (364)
+ Stylus Studio Announcements (113)
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

   
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.