jackrabbit-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Nuescheler <david.nuesche...@gmail.com>
Subject Re: namespaces
Date Wed, 16 Mar 2005 22:27:13 GMT
hi michi,

> 1) I create a node "/authoring"
> 2) I import an XML with the following namespaces:
> <?xml version="1.0" encoding="UTF-8"?>
> <site i18n:attr="label" label="Authoring"
>    xmlns="http://apache.org/cocoon/lenya/sitetree/1.0"
>    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>    xsi:schemaLocation=
>        "http://apache.org/cocoon/lenya/sitetree/1.0
>        ../../../../resources/entities/sitetree.xsd"
>    xmlns:i18n="http://apache.org/cocoon/i18n/2.1"
> >....
> and attach it to the node "/authoring"
> 3) After the import I take a look at the repository with the dump method
> of the FirstSteps example and see
> Node: /authoring/_pre10:site
> Property: /authoring/_pre10:site/jcr:primaryType = nt:unstructured
> Property: /authoring/_pre10:site/i18n:attr = label
> Property: /authoring/_pre10:site/label = Authoring
> Property: /authoring/_pre10:site/xsi:schemaLocation =
> http://apache.org/cocoon/lenya/sitetree/1.0
> ../../../../resources/entities/sitetree.xsd
> which means Jackrabbit "renamed" the prefix of the default namespace
> http://apache.org/cocoon/lenya/sitetree/1.0
> to "_pre10" for its "internal" representation
> 4) I want to retrieve the node
> "/authoring/_pre10:site"
> which works of course ;-) but I don't want to hardcode the prefix
> "_pre10" of course
> because it could be anything, only the namespace should matter. That's
> why I thought
> one has to do it as with XPath.
jackrabbit automatically registers namespaces in the repository 
namespace registry upon xml import in case the namespace is
not already registered.

now, since for the initial registration of a namespace we need
a prefix and a uri. with everything else but the default 
namespace we use the prefix from the xml for the initial 
registration, with default namespaces we cannot come up
with a generally descriptive namespace.

the _preXX should never be used in code but should be 
remapped after the initial registration with registerNamspace()
or should be registered even before your initial import.
[maybe something like lenya-st:]
once registered, the default prefix is set for this namespace
but can also be remapped temporarily (session scoped) or
permanently at any point.

to test how the namespace registry works i would 
suggest looking at:
and see impact on http://jcr.day.com
(to modify you will have to login [admin/admin])

i registered the namespace in question for your 
convenience, and created a node and a prop using 
that namespace.

does that help?


View raw message