Ok, I figured out the the NamespaceResolver is assumed to return "" for the 
empty prefix. 
I.e. after adding 

@Override
    public String getURI(String prefix) throws NamespaceException {
        if (prefix.isEmpty()) {
            return Name.NS_DEFAULT_URI;
        }
....

it worked fine. Worth to mention this implicit assumption though in the javadoc 
https://github.com/apache/jackrabbit/blob/b23d6734381e49f236c3705820126803555608b5/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/namespace/NamespaceResolver.java#L38
 
<https://github.com/apache/jackrabbit/blob/b23d6734381e49f236c3705820126803555608b5/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/namespace/NamespaceResolver.java#L38>.
Will open a PR for that.


> On 13. Feb 2020, at 11:46, Konrad Windszus <[email protected]> wrote:
> 
> So what you are saying is basically that the part inside the {} must contain 
> at least one InvalidChar 
> (https://docs.adobe.com/docs/en/spec/jcr/2.0/3_Repository_Model.html#3.2%20Names
>  <https://docs.adobe.com/docs/en/spec/jcr/2.0/3_Repository_Model.html#3.2 
> Names>) to make Jackrabbit/Oak detect it as a expanded name?
> Why was the default namespace URI then defined as the empty string? That 
> sounds like a mistake to me.
> 
> Currently I cannot even do NameParser.parse() 
> (https://github.com/apache/jackrabbit/blob/b23d6734381e49f236c3705820126803555608b5/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/conversion/NameParser.java#L53
>  
> <https://github.com/apache/jackrabbit/blob/b23d6734381e49f236c3705820126803555608b5/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/conversion/NameParser.java#L53>)
>  for name = "wrongtype".
> It throws an IllegalArgumentException:
> 
> java.lang.IllegalArgumentException: No namespaceURI specified
>       at 
> org.apache.jackrabbit.spi.commons.name.NameFactoryImpl.create(NameFactoryImpl.java:49)
>       at 
> org.apache.jackrabbit.spi.commons.conversion.NameParser.parse(NameParser.java:191)
>       
> with jackrabbit-spi-commons 2.20.0.
> 
> "wrongtype" is IMHO a totally valid qualified name, therefore it shouldn't 
> throw!
> Is this a bug?
> 
> Konrad
> 
> 
>> On 11. Feb 2020, at 15:40, Julian Reschke <[email protected]> wrote:
>> 
>> On 11.02.2020 12:17, Konrad Windszus wrote:
>>> What should be the expanded name for the qualified name "foo" (without URI 
>>> prefix) then?
>> 
>> One could either say that there is none (and you don't need one), or
>> that it is "foo" (and raise a bug against the spec to say that missing
>> leading "{..." in an expanded name implies the empty namespace.
>> 
>>> What namespace URI should be used then?
>> 
>> If "foo" is in no namespace, and you need a namespace name, it would be
>> the empty string.
>> 
>>> I am now totally lost to be honest.
>> 
>> Yes, it's confusing.
>> 
>> It's because in JCR 2.0, expanded names were introduced as an alternate
>> name notation, and we had to find a way not to let expanded names to
>> conflict with qualified names.
>> 
>> The only way to make this work was to require the namespace name not to
>> be empty and to be a valid URI (which implies there's at least one ":"
>> in the namespace name).
>> 
>> Best regards, Julian
> 

Reply via email to