473,411 Members | 2,129 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,411 software developers and data experts.

Traverse XSL stylesheet


I've created an XSL stylesheet that lets me filter data in an
XMLDocument using a transform.

However, I want the filter to be dynamic based on an attribute.

Should I just do a search replace on it?

Or can I pinpoint a specific part of an XSL using the OM?

Jun 13 '06 #1
5 1550


John Bailo wrote:

I've created an XSL stylesheet that lets me filter data in an
XMLDocument using a transform.

However, I want the filter to be dynamic based on an attribute.

Should I just do a search replace on it?

Or can I pinpoint a specific part of an XSL using the OM?


You should define a global parameter e.g.
<xsl:param name="parameterName" />
in the XSLT stylesheet and then use the API of the XSLT processor to set
that parameter before you run a transformation.
In the stylesheet you use the parameter as
$parameterName
in XPath expressions.

Of course manipulation of an XSLT document is possible if you load the
stylesheet in an XmlDocument but defining and setting parameters is the
preferred way. And XPathDocument in .NET, the preferred data store for
XSLT/XPath is read only.

--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Jun 13 '06 #2
Martin Honnen wrote:
You should define a global parameter e.g.
<xsl:param name="parameterName" />
in the XSLT stylesheet and then use the API of the XSLT processor to set
that parameter before you run a transformation.


Are you talking about the XslTransform API?

I don't see a member to set a parameter once I've loaded the stylesheet
and prior to running the Transform.

http://msdn2.microsoft.com/en-us/lib...ds(VS.80).aspx

Jun 13 '06 #3

Actually, your idea is perfect.

I find some implementation code here:

http://www.ischool.washington.edu/ta...Parameters.htm

That is working for me well.

Thanks for your help!!!
John Bailo wrote:
Martin Honnen wrote:
You should define a global parameter e.g.
<xsl:param name="parameterName" />
in the XSLT stylesheet and then use the API of the XSLT processor to
set that parameter before you run a transformation.

Are you talking about the XslTransform API?

I don't see a member to set a parameter once I've loaded the stylesheet
and prior to running the Transform.

http://msdn2.microsoft.com/en-us/lib...ds(VS.80).aspx

Jun 13 '06 #4

I want to use a param in a conditional as in:

<xsl:param name="partnumid"></xsl:param>

<xsl:choose>
<xsl:when $partnumid="">
<xsl:apply-templates select="partnum"/>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates select="partnum[@id=$partnumid]"/>
</xsl:otherwise>
</xsl:choose>

However, during run time, this exception occurs:

6/14/2006 9:37:20 AM:Search:System.Xml.XmlException: The '$' character,
hexadecimal value 0x24, cannot begin with a name. Line 40, position 15.
So, I can use $partnumid in the select statement (in quotes) but not as
a variable in the when clause.

Is there some other way to express the value of the partnumid?

John Bailo wrote:

Actually, your idea is perfect.

I find some implementation code here:

http://www.ischool.washington.edu/ta...Parameters.htm
That is working for me well.

Thanks for your help!!!
John Bailo wrote:
Martin Honnen wrote:
You should define a global parameter e.g.
<xsl:param name="parameterName" />
in the XSLT stylesheet and then use the API of the XSLT processor to
set that parameter before you run a transformation.


Are you talking about the XslTransform API?

I don't see a member to set a parameter once I've loaded the
stylesheet and prior to running the Transform.

http://msdn2.microsoft.com/en-us/lib...ds(VS.80).aspx

Jun 14 '06 #5


John Bailo wrote:

I want to use a param in a conditional as in:

<xsl:param name="partnumid"></xsl:param>

<xsl:choose>
<xsl:when $partnumid="">


That is not proper XML/XSLT syntax, you probably want
<xsl:when test="$partnumid = ''">
--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Jun 14 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Matt | last post by:
Is it possible to traverse the values of children of an element, and no need to specify the children's element names in XSLT element? The XML file can be <bio> <skills> <languages>...
3
by: john | last post by:
I am using ASP.NET and I have a datagrid. One of the columns in my grid is all checkboxes. When the user clicks on a certain button on the page, which is not in the grid, I want to be able to...
3
by: R. Rajesh Jeba Anbiah | last post by:
Unfortunately, I couldn't find any way to traverse the object array in reverse order. I'd thought there must be a way to do it with for..in loop, but couldn't find anything yet. Could someone...
0
by: Egil Hansen | last post by:
Hi all I've written a class that will traverse a folder and its subfolders for every file that older then a specific time span. I do this through a recursive call to a method I call "Traverse",...
2
by: john | last post by:
I posted this question to comp.lang.javascript but didn't get a response, so I'll try here. I am using ASP.NET and I have a datagrid. One of the columns in my grid is all checkboxes. When the...
5
by: Bob Day | last post by:
Using vs 2003, vb.net It is not clear from the documentation, but it appears that a raised event will traverse up the call stack upwards until it reaches its handler. Is this correct? See the...
3
by: visor7 | last post by:
Hi, i've been trying to investigate how to traverse through an object instance properties or fields with no success. I have read about IEnumerable interface but that seems to apply only to...
1
by: SonOfGrey | last post by:
Hi! I'm looking for a way to traverse all the controls on a dialog in the order of the tabstop index. Note that I use unmanaged C++, so no GetTabIndex function afaik. The ALMOST perfect...
2
by: rvimalram | last post by:
Hi all, I have a created a multidimesional array,what i need is to traverse that array and return the value of the array in the particular page the array is $one=array("one" =>"Text1");...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.