Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

setProperty with full namespace not working #325

Open
pavelvondrasek opened this issue Jan 31, 2017 · 4 comments
Open

setProperty with full namespace not working #325

pavelvondrasek opened this issue Jan 31, 2017 · 4 comments

Comments

@pavelvondrasek
Copy link
Contributor

I tried to update documentation in Dbal.

I wrote this code:

// see Bootstrapping for how to get the session 
use PHPCR\NodeType\NodeTypeInterface;

$rootNode = $session->getNode('/');
$whitewashing = $rootNode->addNode('www-whitewashing-de');
$session->save();

$posts = $whitewashing->addNode('posts');
$session->save();

$post = $posts->addNode('welcome-to-blog');

$post->addMixin(NodeTypeInterface::MIX_TITLE);
$post->setProperty(PropertyInterface::JCR_TITLE, 'Welcome to my Blog!');
$post->setProperty(PropertyInterface::JCR_DESCRIPTION, 'This is the first post on my blog! Do you like it?');

$session->save();

$post->setProperty(PropertyInterface::JCR_TITLE, 'Welcome to my Blog!'); throws
( ! ) Fatal error: Uncaught PHPCR\NamespaceException: Mapping for '{http' is not defined in /Users/pavel/Sites/jackalope-doctrine-dbal/vendor/jackalope/jackalope/src/Jackalope/NamespaceRegistry.php on line 189

Maybe setProperty isn't able to work with property name in extended form?

@dbu dbu changed the title Something wrong in setProperty setProperty with full namespace not working Jan 31, 2017
@dbu
Copy link
Member

dbu commented Jan 31, 2017

i actually am not sure if setProperty is supposed to extended form namespaces, or only namespace prefix. does the jcr specification tell? (and if its not allowed, then i don't really know what the constants on PropertyInterface are good for)

@pavelvondrasek
Copy link
Contributor Author

"While a JCR name is an ordered pair of strings, (N, L), it is not itself a string. There are, however, two lexical forms (string serializations) that a JCR name can take when used in the JCR API: the expanded form and the qualified form. A JCR name that is converted to either lexical form is said to have been lexicalized."

ExpandedName ::= '{' Namespace '}' LocalName

QualifiedName ::= [Prefix ':'] LocalName

3.2.6 Use of Qualified and Expanded Names

When a JCR name is passed as an argument to a JCR method it may be in either expanded or qualified form. When a repository returns a JCR name it must be in qualified form. The qualified form of a name depends upon the prevailing local namespace mapping of the current session (see §3.5 Namespace Mapping).

@pavelvondrasek
Copy link
Contributor Author

btw I think our nomenclature in PHPCR "extended" form is wrong. In specs is used expanded :)

@dbu
Copy link
Member

dbu commented Jan 31, 2017

okay, looks like we don't respect the spec part about expanded. probably not the most urgent thing to fix, using qualified names is good enough. afaik things like JCR_TITLE are not supposed to be used for your own content, but only for the predefined node types fields.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants