You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jackrabbit.apache.org by Dan Connelly <ds...@adelphia.net> on 2006/11/13 15:18:35 UTC

Roundtripping: Stripping JCR metadata

Is there a handy example of stripper code to eliminate JCR metadata, 
using either a ContentHandlerl or an XSLT?

Seems like there should be standardized way to achieve roundtripping.   
Or, is the stripping task so trivial that the obvious first attempt 
(throwing out properties with jcr prefix) is going to do the job?

       --Dan

Re: Roundtripping: Stripping JCR metadata

Posted by Jukka Zitting <ju...@gmail.com>.
Hi,

On 11/13/06, Stefan Guggisberg <st...@gmail.com> wrote:
> back to your question: probably the easiest approach would be to use
> a custom ContentHandler that filters jcr:* properties and nodes.

Another good approach would be to extend the DocumentViewExportVisitor
class from the jcr-ext contrib project. A code snippet like the
following would produce a document view XML export without any jcr:*
properties.

    Node node = ...;
    ContentHandler handler = ...;
    node.accept(new DocumentViewExportVisitor(handler, true, false) {
        protected boolean includeProperty(Property property)
                throws RepositoryException {
            return !property.getName().startsWith("jcr:");
        }
    });

Note that the DocumentViewExportVisitor class is still experimental code.

BR,

Jukka Zitting

Re: Roundtripping: Stripping JCR metadata

Posted by Stefan Guggisberg <st...@gmail.com>.
On 11/13/06, Dan Connelly <ds...@adelphia.net> wrote:
> Is there a handy example of stripper code to eliminate JCR metadata,
> using either a ContentHandlerl or an XSLT?
>
> Seems like there should be standardized way to achieve roundtripping.
> Or, is the stripping task so trivial that the obvious first attempt
> (throwing out properties with jcr prefix) is going to do the job?

first of all i'd like point out that document view roundtripping is not
guaranteed for a number of reasons, e.g. xml comments are not
processed, (scoped) ns declarations are not preserved, formatting
is not preserved etc etc. document view xml format is IMO inherently
flawed and was never intented for roundtripping.

back to your question: probably the easiest approach would be to use
a custom ContentHandler that filters jcr:* properties and nodes.

cheers
stefan

>
>        --Dan
>