RE: [xsl] xsl:param and attribute testing

Subject: RE: [xsl] xsl:param and attribute testing
From: "Reuel Alvarez" <ralvarez@xxxxxxxxxxxx>
Date: Tue, 30 Jan 2001 09:52:02 -0500
Dimitre,
I think I understand what you're saying-- chain the xml output of a
parameterized stylesheet to another parameterized stylesheet, and so on.
I'm using xalan-java, so I believe the code would look like this:

for(int i = start_id; i <= end_id; i++) {
	xsltProcessor.setStylesheetParam("id", xslProcessor.createXString(i));

xsltProcessor.setStylesheet(xsltProcessor.processStylesheet(xslInputStream))
;
	xsltProcessor.process(xmlSource, null, xmlSource);
}

Is it also possible to pass in a comma-separated list, parse it with xsl
functions, and then feed that into a template?


-----Original Message-----
From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx
[mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx]On Behalf Of Dimitre
Novatchev
Sent: Tuesday, January 30, 2001 12:19 AM
To: ralvarez@xxxxxxxxxxxx
Cc: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: Re: [xsl] xsl:param and attribute testing


Reuel,

> <xsl:variable name="acount" select="count(Analyst/@id[text()=10
> or text()=103 or text()=998]) + 1" />

Attribute nodes do not have any children, so this test (@id[Text()=10])
will never return true. The test that will perform as you expected will
be:

@id[. = 10]


> Is there any way to pass the attributes 10, 103, and 998 (or any
other set
> of numbers) to the stylesheet using xsl:param?

Yes, you can pass parameters to a template from another template if you
specify xsl:with-param elements within the contents of the
xsl:apply-templates or xsl:call-template. The value of the @name
attribute of an xsl:param must be one of the values of the @name
attributes of an xsl:param of the template being called/applied.

It seems to me, that what you really want is to pass parameters into
your stylesheet ***externally***.

This can be done and is vendour-dependent. Typically, using DOM in your
script, you manipulate the nodes of your loaded stylesheet and change
the value of the @select attribute of an xsl:param or a xsl:variable.

Then you apply the transformation.

Dimitre Novatchev.


Reuel Alvarez wrote:

I'd like to be able to pass a parameter to my xsl stylesheet that will
count
nodes with specific attributes.  For example, I'd like to count Analyst
elements whose analyst_id attributes are 10, 103, or 998 like so:

<xsl:template match="Analyst">
<xsl:variable name="acount" select="count(Analyst/@id[text()=10
or text()=103 or text()=998]) + 1" />
<xsl:value-of select="$acount" />
</xsl:template>

Is there any way to pass the attributes 10, 103, and 998 (or any other
set
of numbers) to the stylesheet using xsl:param? Assuming that I can do
that,
how can I specify that the nodes selected contain those parameters that
were
passed?







__________________________________________________
Get personalized email addresses from Yahoo! Mail - only $35
a year!  http://personal.mail.yahoo.com/

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread