Xquery ampersand error

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Xquery ampersand error

Fiona Murphy
Hi all,
I am implementing a search page in my application, which queries an external exist db. I want to know is there a way to use the &= operator that is used in some of the sandbox examples that come with exist? (As i want to be able to search a node of the xml document by keyword)

Currently the xslt processor to build the query I send to exist looks like this:

        <p:processor name="oxf:xslt">
            <p:input name="data" href="#instance"/>
            <p:input name="config">
                <xdb:query collection="/db" create-collection="true" xsl:version="2.0">
                    xquery version "1.0";
                    <document-infos>
                    {  
                        for $d in /document-info[.//jelr:subject &= '<xsl:value-of select="instance//subject"/>']
                        order by xs:dateTime($d/document-date) descending
                        return $d
                    }
                 </document-infos>
                </xdb:query>
            </p:input>
            <p:output name="data" id="query"/>
        </p:processor>

This is throwing an XmlRpcException : unexpected char: '&'

I have also tried enclosing &= in an xsl text element as follows:
<xsl:text disable-output-escaping="yes">&=</xsl:text> but this doesnt work..

Any ideas?
Reply | Threaded
Open this post in threaded view
|

Re: Xquery ampersand error

Ryan Puddephatt
Fiona,
    To get around this I normally assign &amp; to a variable

<xsl:variable name="amp">&amp;</xsl:variable>

then use value-of to apply it

<xsl:value-of select="$amp"/>

This might work in you case, otherwise you will have to double escape it with

&amp;amp;

HTH

Ryan

Ryan Puddephatt
Software Engineer
 
Teleflex Group - IT UK
1 Michaelson Square
Livingston
West Lothian
Scotland
EH54 7DP
 
e> [hidden email]
t> +44(0)1506 407 110
f> +44(0)1506 407 108
w> www.teleflex.com



Fiona Murphy wrote:
Hi all,
I am implementing a search page in my application, which queries an external
exist db. I want to know is there a way to use the &= operator that is used
in some of the sandbox examples that come with exist? (As i want to be able
to search a node of the xml document by keyword)

Currently the xslt processor to build the query I send to exist looks like
this:
<!-- Dynamically build query -->
        <p:processor name="oxf:xslt">
            <p:input name="data" href="#instance"/>
            <p:input name="config">
                <xdb:query collection="/db" create-collection="true"
xsl:version="2.0">
                    xquery version "1.0";
                    <document-infos>
                    {  
                        for $d in /document-info[.//jelr:subject &amp;=
'<xsl:value-of select="instance//subject"/>']
                        order by xs:dateTime($d/document-date) descending
                        return $d 
                    }
                 </document-infos>
                </xdb:query>
            </p:input>
            <p:output name="data" id="query"/>
        </p:processor>

This is throwing an XmlRpcException : unexpected char: '&' 

I have also tried enclosing &= in an xsl text element as follows:
<xsl:text disable-output-escaping="yes">&=</xsl:text> but this doesnt work..

Any ideas?

  

-- You receive this message as a subscriber of the [hidden email] mailing list. To unsubscribe: [hidden email] For general help: [hidden email] ObjectWeb mailing lists service home page: http://www.objectweb.org/wws


--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: Xquery ampersand error

Fiona Murphy
Ryan,

I've discovered that the xquery contains function achieves what I want as well.
Thanks for your suggestions,

Fiona


Fiona
Ryan Puddephatt wrote
Fiona,
    To get around this I normally assign & to a variable

<xsl:variable name="amp">&</xsl:variable>

then use value-of to apply it

<xsl:value-of select="$amp"/>

This might work in you case, otherwise you will have to double escape it
with

&amp;

HTH

Ryan

Ryan Puddephatt
Software Engineer
 
Teleflex Group - IT UK
1 Michaelson Square
Livingston
West Lothian
Scotland
EH54 7DP
 
e> rpuddehatt@teleflex.com <mailto:rpuddephatt@teleflex.com>
t> +44(0)1506 407 110
f> +44(0)1506 407 108
w> www.teleflex.com <http://www.teleflex.com>



Fiona Murphy wrote:
> Hi all,
> I am implementing a search page in my application, which queries an external
> exist db. I want to know is there a way to use the &= operator that is used
> in some of the sandbox examples that come with exist? (As i want to be able
> to search a node of the xml document by keyword)
>
> Currently the xslt processor to build the query I send to exist looks like
> this:
>
>         <p:processor name="oxf:xslt">
>             <p:input name="data" href="#instance"/>
>             <p:input name="config">
>                 <xdb:query collection="/db" create-collection="true"
> xsl:version="2.0">
>                     xquery version "1.0";
>                     <document-infos>
>                     {  
>                         for $d in /document-info[.//jelr:subject &=
> '<xsl:value-of select="instance//subject"/>']
>                         order by xs:dateTime($d/document-date) descending
>                         return $d
>                     }
>                  </document-infos>
>                 </xdb:query>
>             </p:input>
>             <p:output name="data" id="query"/>
>         </p:processor>
>
> This is throwing an XmlRpcException : unexpected char: '&'
>
> I have also tried enclosing &= in an xsl text element as follows:
> <xsl:text disable-output-escaping="yes">&=</xsl:text> but this doesnt work..
>
> Any ideas?
>
>  
> ------------------------------------------------------------------------
>
>
> --
> You receive this message as a subscriber of the ops-users@objectweb.org mailing list.
> To unsubscribe: mailto:ops-users-unsubscribe@objectweb.org
> For general help: mailto:sympa@objectweb.org?subject=help
> ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
>  


--
You receive this message as a subscriber of the ops-users@objectweb.org mailing list.
To unsubscribe: mailto:ops-users-unsubscribe@objectweb.org
For general help: mailto:sympa@objectweb.org?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws