Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CDATA XML Mapping #62

Open
kovax opened this issue Oct 13, 2016 · 2 comments
Open

CDATA XML Mapping #62

kovax opened this issue Oct 13, 2016 · 2 comments

Comments

@kovax
Copy link

kovax commented Oct 13, 2016

I would like to be able marshall and unmarshall the following XML:

<cristalquery name="TestQuery" version="0">
    <query language="existdb:xquery"><![CDATA[
<TRList>{
    for $prop in collection('weighbridge')/Property[@name='Type']
    where $prop = "Weighbridge"
    return local:queryTransaction(util:collection-name($prop))
}</TRList>
    ]]></query>
</cristalquery>

As you can see it contains an XQuery, and to store that unescaped I am need to use CDATA. Currently I am planning to implemenet a custom FieldHandler, but I think it would be great if castor could support CDATA with a mapping like bellow, i.e. uses node="cdata" in the last field:

<mapping>
    <class name="org.cristalise.kernel.querying.Query">
        <map-to xml="cristalquery"/>
        <field name="name" type="string" direct="false">
            <bind-xml name="name" node="attribute" />
        </field>
        <field name="version" type="integer" direct="false">
            <bind-xml name="version" node="attribute" />
        </field>
        <field name="language" type="string" direct="false">
            <bind-xml name="language" location="query" node="attribute" />
        </field>
        <field name="query" type="string" direct="false">
            <bind-xml name="query" node="cdata" />
        </field>
    </class>
</mapping>

org.w3c.dom.CDATASection is a subclass of Text, so it should not be hard to handle the ![CDATA...]] wrapper around that text.

@ramanujamsridhar
Copy link

I agree. is this available with latest version of castor ?

@kovax
Copy link
Author

kovax commented Jun 8, 2017

I would appreciate any feedback on this. I could contribute this functionality, but I would need some guidance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants