[dna-issues] [JBoss JIRA] Commented: (DNA-378) XML Graph Importer should support importing multi-valued properties
Randall Hauch (JIRA)
jira-events at lists.jboss.org
Mon Apr 27 15:22:46 EDT 2009
[ https://jira.jboss.org/jira/browse/DNA-378?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12464689#action_12464689 ]
Randall Hauch commented on DNA-378:
-----------------------------------
Brian, did you mean to say "there doesn't seem a way to add a property VALUE ..." ? The current graph API does allow you to set a property on a node, even if that node was created in a previous request (even if they're in the same batch). For example, I can create a node (maybe supplying a handful of properties), and then call setProperty(x).on(samePath) and that will work just fine. In fact, if setProperty is called right after the create, then the set property request even get merged into create request. The graph API currently doesn't allow adding a value to a property; this is the heart of DNA-379.
The importer should already be keeping track of the path given the current stack, and you should always be able to set a property on the node (even after any child elements have just been finished). The only tricky part is that to handle multi-valued properties (i.e., where each value is represented by a different child element's content), then the importer might have to keep a map of the properties set via child elements (and overwrite them if additional child elements are read with additional values for a property), and set them only when the element is ended. If I'm correct, then it shouldn't matter whether the property child elements come before child elements, or in what order the property child elements appear.
It just means that the importer has to maintain a stack of properties for each "incomplete node" (or do this on the existing stack).
Waiting for DNA-379 would allow this to work without having to maintain the properties in the stack, since the processing of each child node (with content) would mean just adding that value to the property with the given name. I agree it would be easier. The only question is whether it's worth doing DNA-379 in 0.4.
> XML Graph Importer should support importing multi-valued properties
> --------------------------------------------------------------------
>
> Key: DNA-378
> URL: https://jira.jboss.org/jira/browse/DNA-378
> Project: DNA
> Issue Type: Feature Request
> Components: API, Graph
> Reporter: Randall Hauch
> Fix For: 0.4
>
>
> The XML handler used in the Graph importer (that is, org.jboss.dna.graph.xml.XmlHandler) does not currently support producing multi-valued properties. This is a fairly substantial limitation.
> The current XML handler simply maps an XML element to a graph node and an XML attribute to a property. There is no such thing as multi-valued XML attributes, so another mapping has to be used for multi-valued properties. Since a graph node does not directly hold any values (rather, it holds properties that have the values), and the XML handler currently ignores all XML character content (e.g., <element>this is character content</element>), it is fairly logical to conclude that a child XML element with character content should be mapped to a property. If there is a "jcr:name" attribute, then this attribute's value would be used to determine the property name (meaning the element's name could be anything); otherwise, the child element's name would be the property name.
> This would also address the shortcoming of XML attribute values not being able to (easily) have any character content, since such property values could be placed in a child element.
> Here's an example:
> <cars>
> <car jcr:name="Mini">
> <jcr:description>This is a description that would be stored as a property on the 'Mini' node</jcr:description>
> <property jcr:name="summary">This is the value of the 'summary' property on the 'Mini' node</property>
> </car>
> </cars>
> I'm not sure how easy it is to change the XmlHandler to behave this way, since under certain situations it may require postponing the creation of a node since it is unknown when processing a "startElement" method that the element has character content. However, I believe that it is worth any additional complexity to make the XML more intuitive and natural.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: https://jira.jboss.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the dna-issues
mailing list