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 (1126)
+ Stylus Studio Technical Forum (13836)
+ Website Feedback (244)
- XSLT Help and Discussion (7447)
-> + Help: convert without parent e... (2)
-> - Correct my substring function ... (1)
-> + Old xsl into reports (4)
-> + How to save xslt converted fil... (3)
-> + How to find non tagging text? (5)
-> + Help: Hex entity to Character... (6)
-> + EDI QUOTES MESSAGE NEED TO REP... (2)
-> + How to convert in multi level ... (4)
-> + Need some help with a styleshe... (3)
-> - Conditional Formattinf Formula... (1)
-> + Creating HTML Unordered LIsts.... (2)
-> + xslt params uknown number of i... (2)
-> + How to use fonts other than ba... (2)
-> - Converting existing HTML into ... (1)
-> + Help to tune up this XSLT (2)
-> + XSLT - is only converting the ... (2)
-> + XSLT Editor tab (4)
-> + Convert multiple files from XM... (2)
-> + how to use in select expressi... (2)
-> + Help needed in XSL transformat... (2)
-> + How to add a string with math ... (5)
-> + How to add a string with math ... (6)
-> - br element (1)
-> + Stylesheet directed terminatio... (2)
-> + Who can help me whit sum funct... (2)
-> + XSLT Works in Stylus Studio, n... (3)
-> - Filter by Attribute (1)
-> + Display x number of items whic... (6)
-> + MultiColumn Reporting (3)
-> + cant get namespace declaration... (3)
-> + Performance xsl:for each and n... (3)
-> + How to assign value to a XSLT ... (3)
-> + Select element value based on ... (2)
-> + Version 10 of Saxon? (8)
-> + How to get the value of a node... (5)
-> + Display Xpath using (4)
-> + XSLT to report (2)
-> + xslt help for a noobie (2)
-> + XSL-FO XML to PDF with XSLT (3)
-> + Using XSLT to transform XML to... (4)
-> + XSLT to sort a list alphabetic... (4)
-> + How to Get Colum Values based ... (2)
-> + non persisting predicate filte... (5)
-> + HTML to XSLT (2)
-> + extra carriage returns in "csv... (2)
-> + extra carriage returns in "csv... (3)
-> - XSLT slicing and orphan contro... (1)
-> + How to delete CDATA using XSL... (15)
-> + Remove only root namespace, bu... (3)
-> + String Parsing (3)
-> + Calling Java method from XSL (3)
-> + populate xsl file from xsd fil... (5)
-> + formating a number like #'###.... (3)
-> + Help with grouping children, f... (20)
-> + Need help for newbie! (3)
-> + xpath in string format (2)
-> + How to populate elements at ra... (4)
-> + Changing Date format in XLST (2)
-> + Please help....How could I rem... (2)
-> + Counting children and grandchi... (7)
-> + Nested tags (4)
-> + Problem with XSLT on a Soap En... (2)
-> + Problem with XSLT on a Soap En... (5)
-> + Comparison between XSLT proces... (2)
-> + Printing non-existing value (9)
-> + big input file for XSLT (14)
-> + Is there any way to store xpat... (2)
-> + Encoding special charecters (2)
-> + Sorting (3)
-> + XML to PDF using XSL:FO (3)
-> + How to find the line number in... (2)
-> + How to set a marker for paper ... (2)
-> + Not equality Function (2)
-> + Counting Elements (4)
-> + Looking for help or code samp... (2)
-> + Help needed in pattern matchin... (2)
-> + Repeaters and Ifs (2)
-> + select adjacent nodes in xpath... (3)
-> + Stripping of Empty Target Elem... (2)
-> + auto-generate Edifact Intercha... (5)
-> + Qname Error in xsl:element (2)
-> + [Newbie] Type conversion and f... (2)
-> + Do ...when (2)
-> + Using Key (3)
-> + sorting elements in option (2)
-> + NaN(not available) value repla... (3)
-> + infinite loop error when tryin... (9)
-> + Escape a character in the stri... (3)
-> + find sum of 2 elements in xml (2)
-> + placing a ' * ' by reading the... (3)
-> + Problem in dispaying Current D... (4)
-> + Merging Table Cells in XSLT re... (3)
-> + xsl fo block-container and foo... (2)
-> + Is is possible to create a .CO... (2)
-> + printing a parent node value i... (2)
-> + Mime header info setup? (3)
-> + Calculating a Date based on 4 ... (3)
-> + XSLT formatting number issue (10)
-> + map repeating elements separat... (3)
-> + Combining XML elements based o... (3)
-- Previous [301-320] [321-340] [341-360] Next
+ XQuery Help and Discussion (1870)
+ Stylus Studio FAQs (159)
+ Stylus Studio Code Samples & Utilities (361)
+ Stylus Studio Announcements (113)
Topic  
Postnext
Sean SymesSubject: Xpath predicate numeric vs string help...
Author: Sean Symes
Date: 12 Jul 2005 06:36 AM
Hi all,
I've got a problem using predicates when searching on values of elements. In short the xpath statement below works if the value of an element in the predicate part is numeric, if however I change the value of the element to a string it doesn't work.
See the two code snippets below;
----- WORKS -----
XML (element value is 3)
<loop name="Party Identification">
<segment name="Name and Address">
<element ref_des="NAD01">
3
</element>
<element ref_des="NAD03">
Hello world
</element>
.... other elements I want to get data from

XSL
<xsl:value-of select="//loop[@name='Party Identification']/segment[element[@ref_des='NAD01']=3]/element[@ref_des='NAD03']"/>

----- FAILS -----
XML (element value is 'ABC')
<loop name="Party Identification">
<segment name="Name and Address">
<element ref_des="NAD01">
ABC
</element>
<element ref_des="NAD03">
Hello world
</element>
.... other elements I want to get data from

XSL
<xsl:value-of select="//loop[@name='Party Identification']/segment[element[@ref_des='NAD01']='ABC']/element[@ref_des='NAD03']"/>

Any help welcome.
Sean.

Postnext
Ivan PedruzziSubject: Xpath predicate numeric vs string help...
Author: Ivan Pedruzzi
Date: 12 Jul 2005 09:23 PM
Sean,

The second expression should work.

Here is a test

Input XML:

<?xml version="1.0"?>
<loop name="Party Identification">
<segment name="Name and Address">
<element ref_des="NAD01">ABC</element>
<element ref_des="NAD03">Hello world</element>
</segment>
</loop>


XSLT:

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

<xsl:template match="/">
<xsl:value-of select="//loop[@name='Party Identification']/segment[element[@ref_des='NAD01']='ABC']/element[@ref_des='NAD03']"/>
</xsl:template>

</xsl:stylesheet>

result:

Hello world


Hope this helps
Ivan Pedruzzi
Stylus Studio Team




Posttop
Sean SymesSubject: Xpath predicate numeric vs string help...
Author: Sean Symes
Date: 12 Jul 2005 10:21 PM
Thanks Ivan for your help.
I worked out the problem, basically the value for "<element ref_des="NAD01">" was on the next line with spaces preceeding it to "tab" it in, with the corresponding end tag on the line below that. When doing a string search the xpath parser was including the preceeding spaces as part of the search criteria. Take out the "formatting" and the statement worked, this also explains why numerics were working.

Cheers, Sean.

   
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-2011 All Rights Reserved.