XML type compatibility with MySQL Types

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

XML type compatibility with MySQL Types

ambarish.gore
Hi Everyone,

Posting this again on ops-users instead of ops-dev.....

I was wondering if someone can help with this problem.  I am running OPS
3.0.1 with Tomcat 4.1 and MySQL 5.0.

Bit of background...my web app enables users to search for xml documents that
are stored within the mySQL db.  The first page lists all xml invoice docs it
finds.  The user can then choose to view the invoice details which are
displayed on the next page. Then, by clicking a button the user can approve
the document which updates a particular field in the xml doc.

The xml doc is stored in TEXT type column called payload.  So far I can
retrieve the documents and display the xml data using the following code and
letting OPS parse the xml data using odt:xmlFragment type which works
perfectly:

<p:config xmlns:p="http://www.orbeon.com/oxf/pipeline";
          xmlns:sql="http://orbeon.org/oxf/xml/sql";
          xmlns:xs="http://www.w3.org/2001/XMLSchema";
          xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
          xmlns:odt="http://orbeon.org/oxf/xml/datatypes";
          xmlns:oxf="http://www.orbeon.com/oxf/processors";>

    <p:param type="input" name="instance"/>
    <p:param type="output" name="data"/>
   
    <p:processor name="oxf:sql">
        <p:input name="data" href="#instance"/>
        <p:input name="datasource" href="../data-access/datasource-sql.xml"/>
        <p:input name="config">
            <sql:config>
                <result>
                    <sql:connection>
                        <sql:execute>
                            <sql:query>
                                  select document_id, payload
                                  from documents
                                  where document_id = <sql:param
type="xs:string" select="/form/document-id"/>
                            </sql:query>
                            <sql:result-set>
                                <sql:row-iterator>
                                    <document-info>
                                                                             
  <document-id>                                                              
    <sql:get-column type="xs:string" column="document_id"/>
        </document-id>
        <payload>
                <sql:get-column type="odt:xmlFragment" column="payload"/>
<!--                type="oxf:xmlFragment" -->
        </payload>
                                                                       
</document-info>
                                                               
</sql:row-iterator>
                            </sql:result-set>
                        </sql:execute>
                    </sql:connection>
                </result>
            </sql:config>
        </p:input>
        <p:output name="data" ref="data"/>
    </p:processor>

</p:config>


The problem occurs when I try to update the xml doc with new data.  The
following code fails with a "Error attribute "type" has a bad value" error.

<p:config xmlns:p="http://www.orbeon.com/oxf/pipeline";
          xmlns:sql="http://orbeon.org/oxf/xml/sql";
          xmlns:xs="http://www.w3.org/2001/XMLSchema";
          xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
          xmlns:odt="http://orbeon.org/oxf/xml/datatypes";
          xmlns:oxf="http://www.orbeon.com/oxf/processors";>

    <p:param name="document-info" type="input"
schema-href="../schema/document-info.rng"/>
   
    <p:processor name="oxf:sql">
        <p:input name="data" href="#document-info"/>
        <p:input name="datasource" href="../data-access/datasource-sql.xml"/>
        <p:input name="config">
            <sql:config>
                    <sql:connection>
                        <sql:execute>
                                                        <sql:update>
                                                                update
documents set payload =
                                                                       
<sql:param type="odt:xmlFragment" select="/*/payload/*"/>
                                where document_id = <sql:param
type="xs:string" select="/*/document-id"/>
                                                        </sql:update>
                        </sql:execute>
                    </sql:connection>
            </sql:config>
        </p:input>
    </p:processor>

</p:config>

I don't understand why this occurs as there was no compatibility issues when
doing the select.  When I change the payload type to oxf:xmlFragment it still
fails with the same error.  If I change the type to xs:string it updates the
db correctly but leaves out all the xml elements and tags.

Any ideas what's wrong here?

Many Thanks,

Ambarish



--
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: XML type compatibility with MySQL Types

ambarish.gore
Hi All,

A quick update on this case... we managed to figure out what the problem was.  

It seems that the declared OXF namespace currently pointing to "xmlns:oxf="http://www.orbeon.com/oxf/processors">" needs to be overidden locally within SQL:Param and set to "xmlns:oxf="http://orbeon.org/oxf/xml/datatypes" to get around the Type error.

The following code fixes this issue:

<p:config xmlns:p="http://www.orbeon.com/oxf/pipeline"
          xmlns:sql="http://orbeon.org/oxf/xml/sql"
          xmlns:xs="http://www.w3.org/2001/XMLSchema"
          xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
          xmlns:odt="http://orbeon.org/oxf/xml/datatypes"
          xmlns:oxf="http://www.orbeon.com/oxf/processors">

    <p:param name="document-info" type="input" schema-href="../schema/document-info.rng"/>
   
    <p:processor name="oxf:sql">
        <p:input name="data" href="#document-info"/>
        <p:input name="datasource" href="../data-access/datasource-sql.xml"/>
        <p:input name="config">
            <sql:config>
                    <sql:connection>
                        <sql:execute>
                                                        <sql:update>
                                                                update documents set payload =
                                                                        <sql:param xmlns:oxf="http://orbeon.org/oxf/xml/datatypes" type="oxf:xmlFragment" select="//F4FInvoice"/>
                                where document_id = <sql:param type="xs:string" select="/*/document-id"/>
                                                        </sql:update>
                        </sql:execute>
                    </sql:connection>
            </sql:config>
        </p:input>
    </p:processor>

</p:config>

Cheers,
Ambarish

 



--
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: Re: XML type compatibility with MySQL Types

Florent Georges
[hidden email] wrote:

> It seems that the declared OXF namespace currently pointing to
> "xmlns:oxf="http://www.orbeon.com/oxf/processors">" needs to be
> overidden locally within SQL:Param and set to
> "xmlns:oxf="http://orbeon.org/oxf/xml/datatypes" to get around the
> Type error.

  The code below was simplified.

> <p:config xmlns:odt="http://orbeon.org/oxf/xml/datatypes"
>           xmlns:oxf="http://www.orbeon.com/oxf/processors">
>   <sql:param xmlns:oxf="http://orbeon.org/oxf/xml/datatypes"
>              type="oxf:xmlFragment"
>              select="//F4FInvoice"/>
> </p:config>

  Why not simply use odt:xmlFragment, instead of redefining the prefix
binding for 'oxf' ?

    <p:config xmlns:odt="http://orbeon.org/oxf/xml/datatypes"
              xmlns:oxf="http://www.orbeon.com/oxf/processors">
      <sql:param type="odt:xmlFragment" select="//F4FInvoice"/>
    </p:config>

  Regards,

--drkm





















       
 p5.vert.ukl.yahoo.com uncompressed/chunked Tue Aug 22 10:13:40 GMT 2006
       
               
___________________________________________________________________________
Découvrez un nouveau moyen de poser toutes vos questions quelque soit le sujet !
Yahoo! Questions/Réponses pour partager vos connaissances, vos opinions et vos expériences.
http://fr.answers.yahoo.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
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
Reply | Threaded
Open this post in threaded view
|

RE: Re: XML type compatibility with MySQL Types

ambarish.gore
Hi,

Yes, did try that but I still had the Type error.

Ambarish

-----Original Message-----
From: Florent Georges [mailto:[hidden email]]
Sent: 22 August 2006 11:29
To: [hidden email]
Subject: Re: [ops-users] Re: XML type compatibility with MySQL Types

[hidden email] wrote:

> It seems that the declared OXF namespace currently pointing to
> "xmlns:oxf="http://www.orbeon.com/oxf/processors">" needs to be
> overidden locally within SQL:Param and set to
> "xmlns:oxf="http://orbeon.org/oxf/xml/datatypes" to get around the
> Type error.

  The code below was simplified.

> <p:config xmlns:odt="http://orbeon.org/oxf/xml/datatypes"
>           xmlns:oxf="http://www.orbeon.com/oxf/processors">
>   <sql:param xmlns:oxf="http://orbeon.org/oxf/xml/datatypes"
>              type="oxf:xmlFragment"
>              select="//F4FInvoice"/>
> </p:config>

  Why not simply use odt:xmlFragment, instead of redefining the prefix
binding for 'oxf' ?

    <p:config xmlns:odt="http://orbeon.org/oxf/xml/datatypes"
              xmlns:oxf="http://www.orbeon.com/oxf/processors">
      <sql:param type="odt:xmlFragment" select="//F4FInvoice"/>
    </p:config>

  Regards,

--drkm





















       
 p5.vert.ukl.yahoo.com uncompressed/chunked Tue Aug 22 10:13:40 GMT 2006
       
               
___________________________________________________________________________
Découvrez un nouveau moyen de poser toutes vos questions quelque soit le
sujet !
Yahoo! Questions/Réponses pour partager vos connaissances, vos opinions et
vos expériences.
http://fr.answers.yahoo.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
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: XML type compatibility with MySQL Types

Florent Georges
agore wrote:

> Yes, did try that but I still had the Type error.

  In org/orbeon/oxf/processor/sql/sql-processor-config.rng I found
this:

    <attribute name="type">
      <choice>
        <value>oxf:xmlFragment</value>
      </choice>
    </attribute>

  I'm not sure it is an error, but I wonder why it is not a xs:QName,
here.  The same thing is used with other values (for example several
times with xs:...).

  Is it expected?

  Regards,

--drkm




















       
 p4.vert.ukl.yahoo.com uncompressed/chunked Tue Aug 22 12:13:40 GMT 2006
       
               
___________________________________________________________________________
Découvrez un nouveau moyen de poser toutes vos questions quelque soit le sujet !
Yahoo! Questions/Réponses pour partager vos connaissances, vos opinions et vos expériences.
http://fr.answers.yahoo.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
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: Re: XML type compatibility with MySQL Types

Erik Bruchez
Administrator
Florent Georges wrote:

> agore wrote:
>
>> Yes, did try that but I still had the Type error.
>
>   In org/orbeon/oxf/processor/sql/sql-processor-config.rng I found
> this:
>
>     <attribute name="type">
>       <choice>
>         <value>oxf:xmlFragment</value>
>       </choice>
>     </attribute>
>
>   I'm not sure it is an error, but I wonder why it is not a xs:QName,
> here.  The same thing is used with other values (for example several
> times with xs:...).
>
>   Is it expected?
I think the schema could be improved. Specifying that the literal value
must be "oxf:xmlFragment" (an ugly type anyway) or "xs:string" is not
good, as you should be able to map any prefix you want to those types.

-Erik

--
Orbeon - XForms Everywhere:
http://www.orbeon.com/blog/



--
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: Re: XML type compatibility with MySQL Types

Erik Bruchez
Administrator
In reply to this post by ambarish.gore
Ambarish,

Thanks for the feedback! It looks like we used the "oxf:" prefix twice
with different namespace URIs, and this is of course confusing. I
entered a bug to track this:

http://forge.objectweb.org/tracker/index.php?func=detail&aid=306075&group_id=168&atid=350207

-Erik

[hidden email] wrote:

> Hi All,
>
> A quick update on this case... we managed to figure out what the problem was.  
>
> It seems that the declared OXF namespace currently pointing to "xmlns:oxf="http://www.orbeon.com/oxf/processors">" needs to be overidden locally within SQL:Param and set to "xmlns:oxf="http://orbeon.org/oxf/xml/datatypes" to get around the Type error.
>
> The following code fixes this issue:
>
> <p:config xmlns:p="http://www.orbeon.com/oxf/pipeline"
>           xmlns:sql="http://orbeon.org/oxf/xml/sql"
>           xmlns:xs="http://www.w3.org/2001/XMLSchema"
>           xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>           xmlns:odt="http://orbeon.org/oxf/xml/datatypes"
>           xmlns:oxf="http://www.orbeon.com/oxf/processors">
>
>     <p:param name="document-info" type="input" schema-href="../schema/document-info.rng"/>
>    
>     <p:processor name="oxf:sql">
>         <p:input name="data" href="#document-info"/>
>         <p:input name="datasource" href="../data-access/datasource-sql.xml"/>
>         <p:input name="config">
>             <sql:config>
>                     <sql:connection>
>                         <sql:execute>
> <sql:update>
> update documents set payload =
> <sql:param xmlns:oxf="http://orbeon.org/oxf/xml/datatypes" type="oxf:xmlFragment" select="//F4FInvoice"/>
>                                 where document_id = <sql:param type="xs:string" select="/*/document-id"/>
> </sql:update>
>                         </sql:execute>
>                     </sql:connection>
>             </sql:config>
>         </p:input>
>     </p:processor>
>
> </p:config>
>
> Cheers,
> Ambarish
>
>  
>
>
>
> ------------------------------------------------------------------------
>
>
> --
> 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

--
Orbeon - XForms Everywhere:
http://www.orbeon.com/blog/



--
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