472,973 Members | 2,413 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,973 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 1535


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
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...

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.