RE: [xsl] substring-after Not Working in apply-templates

Subject: RE: [xsl] substring-after Not Working in apply-templates
From: "Passin, Tom" <tpassin@xxxxxxxxxxxx>
Date: Wed, 6 Oct 2004 11:10:28 -0400
> From: Ahsan Abbas ASGHAR [mailto:S3047382@xxxxxxxxxxxxxxxxxxx]
> I am trying this statement:
>
> <xsl:apply-templates select="substring-after(@rdf:about,'#')">
> </xsl:apply-templates>
>
> But this gives an error saying:
> MyXSLFile.xsl:39: value of expression cannot be converted to a
node-set

The error message is correct and clear.  Apply-templates works on a
node-set, but your expression returns a string (what else would you
expect "substring-after" to return?).

> Can anyone guide me how can I write the result of this substring-after
> thing into an XML file. Do I have to use any other tag rather than
> xsl:apply-templates or what?

Without knowing any more details of what you are starting with and what
you want to achieve, we can only offer some generic advice.  In this
case, you need to qualify or filter the nodes you select.  You could do
this somewhat as follows -

  select ="*[substring-after(@rdf:about,'#')]"

This would select all nodes, whatever their names, that contain an
rdf:about attribute that has some text after the "#" character.

Cheers,

Tom P

Current Thread