Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 16th, 2006, 10:56 AM
Registered User
 
Join Date: Apr 2006
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default xsl variable

I'm having trouble with the following. Let's say I have a soap message:

<soapenv:Body xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
 <myResponse xmlns="http://whatever">
  <ns1:ObjectReturn xmlns:ns1="whatever">
   <ns1:somefield>true</ns1:somefield>
   <ns1:collection>
    <ns2:SomeObject xmlns:ns2="whatever">
     <ns2:fieldA>2</ns2:fieldA>
     <ns2:rank>2</ns2:rank>
    </ns2:SomeObject>
    <ns2:SomeObject xmlns:ns2="whatever">
     <ns2:fieldA>1</ns2:fieldA>
     <ns2:rank>1</ns2:rank>
    </ns2:SomeObject>
   </ns1:collection>
  </ns1:ObjectReturn>
 </myResponse>
</soapenv:Body>

and I have a variable:

<xsl:variable name="myVar" select="*[local-name()='collection']/*[local-name()='SomeObject']/*[local-name()='fieldA']"/>

this returns me the value of fieldA in the first occurrence of SomeObject. Now to refine it, I want to get the same value but only in the occurrence where rank = 1. How do I do that?

Thanks in advance



 
Old May 17th, 2006, 03:42 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

If you were using conventional QName-based paths, it would be

ns1:collection/ns2:someObject[ns2:rank=1]/ns2:fieldA

You can translate that back into your local-name predicates if you wish.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference





Similar Threads
Thread Thread Starter Forum Replies Last Post
ASSIGNING A JAVA SCRIPT VARIABLE TO A XSL VARIABLE SOMANATHAN10 XSLT 1 February 21st, 2007 04:26 AM
xsl:variable holding name of an xsl:param perissos XSLT 0 December 5th, 2006 07:09 AM
The difference between xsl:variable and xsl:param NEO1976 XML 2 July 24th, 2006 06:05 AM
pass java variable to xsl variable kathy1016cats XSLT 1 June 14th, 2006 06:23 PM
xsl variable in xsl tag? di98svpa XSLT 1 February 10th, 2006 01:41 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.