NTD and prefixed names -> sharepoint

View: New views
7 Messages — Rating Filter:   Alert me  

NTD and prefixed names -> sharepoint

by Dave Brosius-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Greetings,

   Perhaps i am very confused here, (likely), but if one uses a node type definition file in jackrabbit, then node names and property names must have namespace prefixes attached to them, as specified by the ntd.

   Now if we would like to use the same code, without registering the NTD, using sharepoint, Sharepoint complains about the use of the ':' as the prefix/name separator.

So I suppose we need to look at what system we are running, and use

Property p = n.getProperty("myprefix:myprop");

for jackrabbit, and

Property p = n.getProperty("myprop");

for sharepoint.

Am i correct here? I am not sure why one must use prefixed names for node names and property names, Is it not good enough that the type be namespace qualified?

What is the strategy that ones takes here, do i just need to write a method such as

public String getQName(String baseName)
{
    if (ntd_in_force)
      return "myprefix:" + baseName;
    return baseName;
}

and use that all over?

Thanks in advance.
dave


Re: NTD and prefixed names -> sharepoint

by Julian Reschke :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hm.

Maybe you could enlighten us how exactly you're using JCR to talk to
Sharepoint?

BR, Julian

Re: NTD and prefixed names -> sharepoint

by Alexander Klimetschek :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Mon, Aug 4, 2008 at 6:04 PM, Dave Brosius <dbrosius@...> wrote:
> Greetings,
>
>   Perhaps i am very confused here, (likely), but if one uses a node type definition file in jackrabbit, then node names and property names must have namespace prefixes attached to them, as specified by the ntd.

No, it is no "must", you can have node and property names without
namespace prefixes. So you can always use Property p =
n.getProperty("myprop");

You only need to use a namespace for the node type itself, but not for
the names it specifies.

>   Now if we would like to use the same code, without registering the NTD, using sharepoint, Sharepoint complains about the use of the ':' as the prefix/name separator.
>
> So I suppose we need to look at what system we are running, and use
>
> Property p = n.getProperty("myprefix:myprop");
>
> for jackrabbit, and
>
> Property p = n.getProperty("myprop");
>
> for sharepoint.

I am also curious how you get to run the same java code on both
jackrabbit and sharepoint.

Regards,
Alex



--
Alexander Klimetschek
alexander.klimetschek@...

Parent Message unknown Re: NTD and prefixed names -> sharepoint

by Dave Brosius-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

>>No, it is no "must", you can have node and property names without
>>namespace prefixes. So you can always use Property p =
>>n.getProperty("myprop");

Well, If i define my ntd as:

<acme = 'http://www.acme.com/coyote/1.0'>
<nt = 'http://www.jcp.org/jcr/nt/1.0'>

[acme:Plan] > nt:folder
  + 'acme:Anvil' (nt:unstructured)
  + 'acme:Bomb' (nt:unstructured)
  + 'acme:Painted Doorway' (nt:unstructured)


and register this ntd, all is well with the world.

If however, i use an ntd as:


<acme = 'http://www.acme.com/coyote/1.0'>
<nt = 'http://www.jcp.org/jcr/nt/1.0'>

[acme:Plan] > nt:folder
  + 'Anvil' (nt:unstructured)
  + 'Bomb' (nt:unstructured)
  + 'Painted Doorway' (nt:unstructured)

When i attempt to register node types i get:

java.lang.Exception: Failed to register node types
        at Acme.ensureNodeTypeDefs(Acme.java:119)
        at Acme.main(Acme.java:31)
Caused by: org.apache.jackrabbit.core.nodetype.compact.ParseException: Error while parsing 'Anvil' (Acme, line 6)
        at org.apache.jackrabbit.core.nodetype.compact.Lexer.fail(Lexer.java:152)
        at org.apache.jackrabbit.core.nodetype.compact.CompactNodeTypeDefReader.toQName(CompactNodeTypeDefReader.java:653)
        at org.apache.jackrabbit.core.nodetype.compact.CompactNodeTypeDefReader.doChildNodeDefinition(CompactNodeTypeDefReader.java:548)
        at org.apache.jackrabbit.core.nodetype.compact.CompactNodeTypeDefReader.doItemDefs(CompactNodeTypeDefReader.java:360)
        at org.apache.jackrabbit.core.nodetype.compact.CompactNodeTypeDefReader.parse(CompactNodeTypeDefReader.java:218)
        at org.apache.jackrabbit.core.nodetype.compact.CompactNodeTypeDefReader.<init>(CompactNodeTypeDefReader.java:178)
        at org.apache.jackrabbit.core.nodetype.compact.CompactNodeTypeDefReader.<init>(CompactNodeTypeDefReader.java:162)
        at Acme.ensureNodeTypeDefs(Acme.java:93)
        ... 1 more
Caused by: javax.jcr.NamespaceException: No URI for pefix '' declared.
        at org.apache.jackrabbit.spi.commons.namespace.NamespaceMapping.getURI(NamespaceMapping.java:74)
        at org.apache.jackrabbit.spi.commons.conversion.NameParser.parse(NameParser.java:116)
        at org.apache.jackrabbit.spi.commons.conversion.ParsingNameResolver.getQName(ParsingNameResolver.java:62)
        at org.apache.jackrabbit.spi.commons.conversion.DefaultNamePathResolver.getQName(DefaultNamePathResolver.java:61)
        at org.apache.jackrabbit.core.nodetype.compact.CompactNodeTypeDefReader.toQName(CompactNodeTypeDefReader.java:646)
        ... 7 more




Re: NTD and prefixed names -> sharepoint

by Michael Dürig-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

> <acme = 'http://www.acme.com/coyote/1.0'>
> <nt = 'http://www.jcp.org/jcr/nt/1.0'>
>
> [acme:Plan] > nt:folder
>   + 'Anvil' (nt:unstructured)
>   + 'Bomb' (nt:unstructured)
>   + 'Painted Doorway' (nt:unstructured)
>
> When i attempt to register node types i get:
>
> java.lang.Exception: Failed to register node types
> at Acme.ensureNodeTypeDefs(Acme.java:119)
> at Acme.main(Acme.java:31)
> Caused by: org.apache.jackrabbit.core.nodetype.compact.ParseException: Error while parsing 'Anvil' (Acme, line 6)
> at org.apache.jackrabbit.core.nodetype.compact.Lexer.fail(Lexer.java:152)
> at org.apache.jackrabbit.core.nodetype.compact.CompactNodeTypeDefReader.toQName(CompactNodeTypeDefReader.java:653)
> at org.apache.jackrabbit.core.nodetype.compact.CompactNodeTypeDefReader.doChildNodeDefinition(CompactNodeTypeDefReader.java:548)
> at org.apache.jackrabbit.core.nodetype.compact.CompactNodeTypeDefReader.doItemDefs(CompactNodeTypeDefReader.java:360)
> at org.apache.jackrabbit.core.nodetype.compact.CompactNodeTypeDefReader.parse(CompactNodeTypeDefReader.java:218)
> at org.apache.jackrabbit.core.nodetype.compact.CompactNodeTypeDefReader.<init>(CompactNodeTypeDefReader.java:178)
> at org.apache.jackrabbit.core.nodetype.compact.CompactNodeTypeDefReader.<init>(CompactNodeTypeDefReader.java:162)
> at Acme.ensureNodeTypeDefs(Acme.java:93)
> ... 1 more
> Caused by: javax.jcr.NamespaceException: No URI for pefix '' declared.
> at org.apache.jackrabbit.spi.commons.namespace.NamespaceMapping.getURI(NamespaceMapping.java:74)
> at org.apache.jackrabbit.spi.commons.conversion.NameParser.parse(NameParser.java:116)
> at org.apache.jackrabbit.spi.commons.conversion.ParsingNameResolver.getQName(ParsingNameResolver.java:62)
> at org.apache.jackrabbit.spi.commons.conversion.DefaultNamePathResolver.getQName(DefaultNamePathResolver.java:61)
> at org.apache.jackrabbit.core.nodetype.compact.CompactNodeTypeDefReader.toQName(CompactNodeTypeDefReader.java:646)
> ... 7 more
>

You need to define the empty prefix in you .cnd file

<''=''>

Michael

Re: NTD and prefixed names -> sharepoint

by Alexander Klimetschek :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Tue, Aug 12, 2008 at 9:28 PM, Michael Dürig <michael.duerig@...> wrote:
> You need to define the empty prefix in you .cnd file
>
> <''=''>

Isn't this defined somewhere by default? I never came across having to
define that empty prefix...

Maybe it's one cnd that already registered the empty prefix in the
background I have never personally seen in my environment so far ;-)

Regards,
Alex

--
Alexander Klimetschek
alexander.klimetschek@...

Re: NTD and prefixed names -> sharepoint

by Michael Dürig-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Alexander Klimetschek wrote:
>> <''=''>
>
> Isn't this defined somewhere by default? I never came across having to
> define that empty prefix...
>
> Maybe it's one cnd that already registered the empty prefix in the
> background I have never personally seen in my environment so far ;-)
>
The CompactNodeTypeDefReader needs definitions for all name space
prefixes used in a node type definition of the .cnd file. It also
provides a constructor for passing in mappings used but not defined in
the .cnd file. So defining <''=''> is not strictly necessary as long
as the definition is passed to the constructor.

Michael
LightInTheBox - Buy quality products at wholesale price!