XSL/XQuery question.

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

XSL/XQuery question.

SateeshK
Hi,

  I am trying to use an xpl to fetch REST reponses, parse them, and store into exist via xquery.

  However xquery fails when it encounters embedded character sequences such as {}, ==.
  In the xslt processer, is there any way to wrap the entire text so xquery does not fail, or strip out offending characters.
  I tried to strip out {} and that worked fine with some xml, but it's not sufficient for some other input.
 
  How can I treat it as say html that should completely be treated as a sequence of characters by xquery?

Thanks,
- Sateesh.

  <p:processor name="oxf:xslt">
    <p:input name="data" href="#api-response"/>

    <p:input name="config">
      <xsl:stylesheet version="2.0">

      <xsl:template match="/">
        <Response>
          <xsl:apply-templates select="Response/part"/>
        </Response>
      </xsl:template>

      <xsl:template match="part">
         <Id> <xsl:value-of select="@id"/> </Id>
         <Desc> <xsl:value-of select="translate(normalize-space(@description),'{}','()')"/> </Desc>
       </xsl:template>
   
       </xsl:stylesheet>
       </p:input>

        <p:output name="data" id="transformed-data"/>
       </p:processor>
       <p:processor name="oxf:xslt">
       <p:input name="data" href="#transformed-data"/>

       <p:input name="config">
       <xdb:query collection="/db" create-collection="false" xsl:version="2.0">
          xquery version "1.0";

         declare function local:store($node-name as xs:string*) as node()*
         {

            .. code removed ...
       
            let $status := xmldb:store($collection-path,$file-name,$doc)
            return $doc-id
          };

          let $doc := <xsl:copy-of select="/"/>
          return local:store($doc)
       </xdb:query>
     </p:input>

    <p:output name="data" id="query"/>
    </p:processor>

  <p:processor name="oxf:xmldb-query">
    <p:input name="datasource" href="datasource.xml"/>

    <p:input name="query" href="#query"/>

    <p:output name="data" id="status"/>
  </p:processor>
Reply | Threaded
Open this post in threaded view
|

Re: XSL/XQuery question.

Hank Ratzesberger
Hi Sateesh,

This sounds like a recent question, and it was suggested that
a 1.1 feature be used which lets you replace the text the
target by using the attribute replace="text"

http://www.w3.org/TR/xforms11/#submit-data-replacement

Since xpl requires well formed xml.

--Hank


On Feb 27, 2009, at 5:24 AM, SateeshK wrote:

>
> Hi,
>
>   I am trying to use an xpl to fetch REST reponses, parse them, and  
> store
> into exist via xquery.
>
>   However xquery fails when it encounters embedded character  
> sequences such
> as {}, ==.
>   In the xslt processer, is there any way to wrap the entire text  
> so xquery
> does not fail, or strip out offending characters.
>   I tried to strip out {} and that worked fine with some xml, but  
> it's not
> sufficient for some other input.
>
>   How can I treat it as say html that should completely be treated  
> as a
> sequence of characters by xquery?
>
> Thanks,
> - Sateesh.
>
>   <p:processor name="oxf:xslt">
>     <p:input name="data" href="#api-response"/>
>
>     <p:input name="config">
>       <xsl:stylesheet version="2.0">
>
>       <xsl:template match="/">
>         <Response>
>           <xsl:apply-templates select="Response/part"/>
>         </Response>
>       </xsl:template>
>
>       <xsl:template match="part">
>          <Id> <xsl:value-of select="@id"/> </Id>
>          <Desc> <xsl:value-of
> select="translate(normalize-space(@description),'{}','()')"/> </Desc>
>        </xsl:template>
>
>        </xsl:stylesheet>
>        </p:input>
>
>         <p:output name="data" id="transformed-data"/>
>        </p:processor>
>        <p:processor name="oxf:xslt">
>        <p:input name="data" href="#transformed-data"/>
>
>        <p:input name="config">
>        <xdb:query collection="/db" create-collection="false"
> xsl:version="2.0">
>           xquery version "1.0";
>
>          declare function local:store($node-name as xs:string*) as  
> node()*
>          {
>
>             .. code removed ...
>
>             let $status := xmldb:store($collection-path,$file-name,
> $doc)
>             return $doc-id
>           };
>
>           let $doc := <xsl:copy-of select="/"/>
>           return local:store($doc)
>        </xdb:query>
>      </p:input>
>
>     <p:output name="data" id="query"/>
>     </p:processor>
>
>   <p:processor name="oxf:xmldb-query">
>     <p:input name="datasource" href="datasource.xml"/>
>
>     <p:input name="query" href="#query"/>
>
>     <p:output name="data" id="status"/>
>   </p:processor>
>
> --
> View this message in context: http://www.nabble.com/XSL-XQuery- 
> question.-tp22245801p22245801.html
> Sent from the ObjectWeb OPS - Users mailing list archive at  
> Nabble.com.
>
>
> --
> 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
> OW2 mailing lists service home page: http://www.ow2.org/wws
Hank Ratzesberger
NEES@UCSB
Institute for Crustal Studies,
University of California, Santa Barbara
805-893-8042







--
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
OW2 mailing lists service home page: http://www.ow2.org/wws