You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jackrabbit.apache.org by Cris Daniluk <cr...@gmail.com> on 2009/03/05 03:48:49 UTC

differentiating elements and attributes in CND

I apologize if this is a question that has been asked and answered, but it
was difficult to identify in perusing docs/archives. I'm trying to import a
legacy XML format that utilizes elements where attributes should be used.
Rather than map it to a new format for storage in Jackrabbit, I'd like to
keep the existing format so that users are able to XQuery as expected.
However, when I use the following CND:

[recordType] > nt:base, mix:referenceable
  orderable
  - shouldBeAnAttr (string) mandatory

[records]
  - record (recordType) = recordType multiple

I cannot import the following XML:

<records>
  <record><shouldBeAnAttr>ShouldBeTheValueOfAnAttr</shouldBeAnAttr></record>
</records>

It isn't a huge shock that it doesn't work with the CND notation. However, I
can't figure out what the notation *should* be. I've played around with
various options with the + (child) notation, but I can't get it to roll up
the CDATA into a value. Is there a way to do this? Do I need a custom
NodeType?

More importantly, what do others do when trying to import XML like this into
JackRabbit? Since it is all validating against the DTD before submission to
the repository, would it be better off to just leave the recordType as
nt:unstructured?

Thanks for your input!

Cris

Re: differentiating elements and attributes in CND

Posted by Stefan Guggisberg <st...@gmail.com>.
hi cris

On Thu, Mar 5, 2009 at 3:48 AM, Cris Daniluk <cr...@gmail.com> wrote:
> I apologize if this is a question that has been asked and answered, but it
> was difficult to identify in perusing docs/archives. I'm trying to import a
> legacy XML format that utilizes elements where attributes should be used.
> Rather than map it to a new format for storage in Jackrabbit, I'd like to
> keep the existing format so that users are able to XQuery as expected.
> However, when I use the following CND:
>
> [recordType] > nt:base, mix:referenceable
>  orderable
>  - shouldBeAnAttr (string) mandatory
>
> [records]
>  - record (recordType) = recordType multiple
>
> I cannot import the following XML:
>
> <records>
>  <record><shouldBeAnAttr>ShouldBeTheValueOfAnAttr</shouldBeAnAttr></record>
> </records>
>
> It isn't a huge shock that it doesn't work with the CND notation. However, I
> can't figure out what the notation *should* be. I've played around with
> various options with the + (child) notation, but I can't get it to roll up
> the CDATA into a value. Is there a way to do this? Do I need a custom
> NodeType?

no, custom node types won't buy you anything here. xml elements will
always be imported as jcr nodes, xml attributes will be imported as jcr
properties. for more information please see
"6.4.2 Document View XML Mapping" in the jsr 170 spec.

while you could write your own importer, based on the jackrabbit
implementation, i wouldn't advise it.

it's probably better if you transform your xml (i.e. make those
elements attrubutes) before importing it. i am not an xml crack
but i guess it should be relatively easy by using xslt.

cheers
stefan

>
> More importantly, what do others do when trying to import XML like this into
> JackRabbit? Since it is all validating against the DTD before submission to
> the repository, would it be better off to just leave the recordType as
> nt:unstructured?
>
> Thanks for your input!
>
> Cris
>