Re: [xml] contains() argument treated like XPath expression

Well I think that's a problem with your understanding of what xpath is.
It's xpath that defines the existance of contains (e.g. to support
node selections like Âp[contains("bla",.)]Â. So this is part of
xpath and the xpath spec defines what it does.

Yes, contains(string, string) is indeed part of XPath and the XPath spec

"The contains function returns true if the first argument string
contains the second argument string, and otherwise returns false."

That does not say anything about contains() interpreting its arguments
as XPath expressions!  It is very clear and obvious to anyone
uninitiated like myself that the arguments are supposed to be
interpreted as arbitrary strings.  

You are indeed correct about character parsing.   Since I was accessing
libxml2 thru Perl XML::LibXML module, the "\n" is interpreted by Perl
and a 10 passed to the libxml2 layer.   But for some reason that didn't
seem to work so I began to suspect that something else might be wrong. 
Please forgive my haste.  By this point I had become quite frustrated.

I might also mention that I didn't access "contains()" directly, but
rather through the "str:subst"
( function
of the XSLTSL (XSLT Standard Library).  When I examined the template for
this function I found that it uses contains().  If I misunderstand the
definition of contains(), I can't be the only one, because the author of
this function uses it exactly the way I would have expected (on the 11th

  <xsl:template name="str:subst">
    <xsl:param name="text"/>
    <xsl:param name="replace"/>
    <xsl:param name="with"/>

      <xsl:when test="string-length($replace) = 0">
        <xsl:value-of select="$text"/>

      <xsl:when test="contains($text, $replace)">
        <xsl:variable name="before" select="substring-before($text,
        <xsl:variable name="after" select="substring-after($text,
        <xsl:value-of select="$before"/>
        <xsl:value-of select="$with"/>
        <xsl:call-template name="str:subst">
          <xsl:with-param name="text" select="$after"/>
          <xsl:with-param name="replace" select="$replace"/>
          <xsl:with-param name="with" select="$with"/>
        <xsl:value-of select="$text"/>  

In any case, the point is now mute, since I accomplished what I needed
using a slightly different strategy.  Nevertheless, thank you for your
response, Morus, which was much kinder than Daniel Veillard's.

Larry Siden

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]