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
Go to previous topicPrev TopicGo to next topicNext Topic
Postnext
(Deleted User) Subject: Confused using match
Author: (Deleted User)
Date: 25 Jul 2006 01:48 PM
Hi,
Can you please tell me what the match does "SALES//*" ? When i change it,the output varies and i am not ables to catch what is happenning.

MY XML TREE
----------
<?xml version="1.0"?>
<SALES>
<SALE>
<REGION>Americas</REGION>
<SOFTWARE>1200</SOFTWARE>
<HARDWARE>850</HARDWARE>
<SERVICES>2000</SERVICES>
<EXTENDED_PRICE>150000.56</EXTENDED_PRICE>
<NET_PRICE>0</NET_PRICE>
<BILLING_CURRENCY>USD</BILLING_CURRENCY>
</SALE>
<SALE>
<REGION>EMEA</REGION>
<SOFTWARE>1000</SOFTWARE>
<HARDWARE>800</HARDWARE>
<SERVICES>1100</SERVICES>
<EXTENDED_PRICE>123456</EXTENDED_PRICE>
<NET_PRICE>123456</NET_PRICE>
<BILLING_CURRENCY>USD</BILLING_CURRENCY>
</SALE>
<SALE>
<REGION>APAC</REGION>
<SOFTWARE>900</SOFTWARE>
<HARDWARE>1200</HARDWARE>
<SERVICES>1500</SERVICES>
<EXTENDED_PRICE>689726</EXTENDED_PRICE>
<NET_PRICE>123456</NET_PRICE>
<BILLING_CURRENCY>USD</BILLING_CURRENCY>
</SALE>
</SALES>

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

<xsl:template match="SALES//*">
<xsl:for-each select="ancestor-or-self::*/SALE">
<xsl:value-of select="ancestor-or-self::*/EXTENDED_PRICE"/>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>

My output is
150000.56123456689726
150000.56123456689726
150000.56123456689726

Case 2 I changed the match to SALE//* it gives me

150000.56123456689726
150000.56123456689726
150000.56123456689726
150000.56123456689726
150000.56123456689726
150000.56123456689726
150000.56123456689726


150000.56123456689726
150000.56123456689726
150000.56123456689726
150000.56123456689726
150000.56123456689726
150000.56123456689726
150000.56123456689726


150000.56123456689726
150000.56123456689726
150000.56123456689726
150000.56123456689726
150000.56123456689726
150000.56123456689726
150000.56123456689726



But my required output is EXTENDED_PRICE of each SALE node..



Please explain me the funda in match and select..I am totally confused..



Thanks,
Dwarak

Posttop
Ivan PedruzziSubject: Confused using match
Author: Ivan Pedruzzi
Date: 25 Jul 2006 07:22 PM
Dwarak

We can't possible tech you a language like XSLT in the scope of message.

Please search "XSLT XPath tutorial" on google.

If you need to simply display all extened prices do the following

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

<xsl:template match="text()"/>

<xsl:template match="EXTENDED_PRICE">
<xsl:value-of select="concat(. , '&#10;')"/>
</xsl:template>

</xsl:stylesheet>

Hope this helps
Ivan Pedruzzi
Stylus Studio Team

 
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.