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 10 11 12 13 14 15 16 17 18 19 20 Go to previous topicPrev TopicGo to next topicNext Topic
Postnext
Oleg TudorSubject: [Context] variable
Author: Oleg Tudor
Date: 02 Feb 2009 03:12 PM
I see a [Context] variable listed in the Variables window. How can I access its value so I can use it into a test condition for example?

Postnext
Ivan PedruzziSubject: [Context] variable
Author: Ivan Pedruzzi
Date: 03 Feb 2009 12:01 PM
Hi Oleg,

[Context] in the variable window can be access using . in your XSLT code, for example

<xsl:for-each select="books/book/title">
<xsl:if test="string-length(.) > 1">
<Title>
<xsl:value-of select="."/>
</Title>
</xsl:if>
</xsl:for-each>


Hope this helps
Ivan Pedruzzi
Stylus Studio Team

Postnext
Oleg TudorSubject: [Context] variable
Author: Oleg Tudor
Date: 03 Feb 2009 01:27 PM
I am sorry, I thik I was not clear enough.

What I am tying to is to check on the [Context] variable, and if my condition is met to do something.

The problem I have is that I am trying to do something different on nodes of the same type based on their relative position with eachother. Basically on the first node I want to do something different than on the second node of the same type and so on. I need to check on the position of that type of node relative to eachother. Debugging my stylesheet I just noticed that [Context] variable does exactly what I was needed, therefore I am trying to check on its value so I can make my decisions.

sample code

<mwp>

<task>
<step><para>.....</para></step>
<step><para>.........</para></step>
<step><para.................</para></step>
</task>

<task>
<step><para>.....</para></step>
<step><para>.........</para></step>
<step><para.................</para></step>
</task>

<task>
<step><para>.....</para></step>
<step><para>.........</para></step>
<step><para.................</para></step>
</task>

<task>
<step><para>.....</para></step>
<step><para>.........</para></step>
<step><para.................</para></step>
</task>

</mwp>

For this sample code I am interested in the <task> node. As you can see I have 4 <task> nodes. On the second <task> node I want to perform a different action than on the third <task> node.

Thank you for any help.

Posttop
Ivan PedruzziSubject: [Context] variable
Author: Ivan Pedruzzi
Date: 03 Feb 2009 02:52 PM

The function position() can help you here , see the example attached


Ivan Pedruzzi
Stylus Studio Team


Documentcontext.xsl


Unknowncontext.xml

 
Topic Page 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 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.