Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: [xsl] Searching text within a node

From: Michael Ludwig <milu71@---.-->
To: xsl-list@-----.------------.---
Date: 8/4/2009 7:35:00 PM
Lee schrieb am 04.08.2009 um 14:13:12 (-0500):
> 
> I have a block of xml that looks like the following.
> 
>  <Form>
>  <Names>
>   <LastName>Jones</LastName>
>   <LastName>Smith</LastName>
>   <LastName>Anderson</LastName>
>   </Names>
>   </form>

Not well-formed :-)

> I need to display blocks of code only if text matches the 
> text in any of the three nodes(or more) in LastName. So 
> you may have a block of code that should display only if 
> "Jones" is in the above nodes.

michael@wladimir:~/win-dev/XSLT :-) expand -t2 lee.xml
<?xml version="1.0"?>
<Form>
  <Names>
    <LastName>Jones</LastName>
    <LastName>Smith</LastName>
    <LastName>Anderson</LastName>
  </Names>
</Form>
michael@wladimir:~/win-dev/XSLT :-) expand -t2 lee.xsl 
<xsl:stylesheet version="1.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

  <xsl:param name="in" select="'Jones'"/>

  <xsl:template match="Form">
    <xsl:if test="$in = Names/LastName">
      <Match><xsl:copy-of select="$in"/></Match>
    </xsl:if>
  </xsl:template>

</xsl:stylesheet>
michael@wladimir:~/win-dev/XSLT :-) xsltproc lee.xsl lee.xml
<?xml version="1.0"?>
<Match>Jones</Match>
michael@wladimir:~/win-dev/XSLT :-) xsltproc --stringparam in x lee.xsl lee.xml
michael@wladimir:~/win-dev/XSLT :-) # no match, no output

Michael Ludwig

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe@l...>
--~--



transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent