You are viewing a plain text version of this content. The canonical link for it is here.
Posted to general@xml.apache.org by Sean Kelly <ke...@ad1440.net> on 2000/03/24 23:50:41 UTC

XSLT selection by node contents

Hi folks.

This isn't necessarily Xalan-related, but I figure there ought to be at
least a few people proficient in XSL and XPath who could help me out.

I want to have two different xsl:template selections based on the string
contents of the node I'm matching.  For instance, if my document is

<doc>
  <node>
    <location>iiop://whatever</location>
     ...
  </node>
  <node>
    <location>http://whatever</location>
     ...
  </node>
   ...
</doc>

Then I want to key off the fact that some <location> nodes start with
"iiop", and others start with something else.  (No, I'm not in a position to
rewrite the DTD and fix the input document).

I want to write XSLT that looks like:

<xsl:template match="location[starts-with(???,'iiop')]">
   Do one thing.
</xsl:template>
<xsl:template match="not(location[starts-with(???,'iiop')])">
  Do another thing
</xsl:template>

The question is ... what do I put in for ??? that selects the value of the
text node of the location node?  Or is this even the right way to proceed?

Thanks.
--Sean



RE: XSLT selection by node contents

Posted by Jonathan Borden <jb...@mediaone.net>.
Sean Kelly [mailto:kelly@ad1440.net]
> I want to write XSLT that looks like:
>
> <xsl:template match="location[starts-with(???,'iiop')]">
>    Do one thing.
> </xsl:template>
> <xsl:template match="not(location[starts-with(???,'iiop')])">
>   Do another thing
> </xsl:template>
>
> The question is ... what do I put in for ??? that selects the value of the
> text node of the location node?  Or is this even the right way to proceed?
>


	I would try:

	starts-with(.,'ioop') . being the way to express the current node.

	General XSL questions can also be directed to the

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

Jonathan Borden