Hi Tony,

I am a little confused with your statement that using the ":nameHint"
results in documents writing over each other.  Using a ":nameHint" should
result in a new unique node name for each request (See "Algorithm for Node
Name Creation" @ [1]).

I just tried this out locally and this is what I see:

First, create a node with curl:

curl -F":nameHint=blogname" -F"sling:resourceType=mjb/blog" -F"seq=105"
-F"firstName=Roberta" -F"lastName=Chambers"  "http://admin:ad...@localhost
:8080/sling/content/blog/*"

Second, create a second node by running the same command again:

curl -F":nameHint=blogname" -F"sling:resourceType=mjb/blog" -F"seq=105"
-F"firstName=Roberta" -F"lastName=Chambers"  "http://admin:ad...@localhost
:8080/sling/content/blog/*"


Finally, fetching the xml for the parent node shows two child nodes
("blogname" and "blogname_0"):

curl "http://admin:ad...@localhost:8080/sling/content/blog.xml";

...which results in this output:

<?xml version="1.0" encoding="UTF-8"?><blog
jcr:primaryType="nt:unstructured" xmlns:mix="http://www.jcp.org/jcr/mix/1.0";
xmlns:nt="http://www.jcp.org/
jcr/nt/1.0" xmlns:fn_old="http://www.w3.org/2004/10/xpath-functions";
xmlns:sling="http://sling.apache.org/jcr/sling/1.0"; xmlns:fn="
http://www.w3.org/2
005/xpath-functions" xmlns:ocm="http://jackrabbit.apache.org/ocm"; xmlns:xs="
http://www.w3.org/2001/XMLSchema"; xmlns:sv="http://www.jcp.org/jcr/sv/1.0";
 xmlns:rep="internal" xmlns:jcr="http://www.jcp.org/jcr/1.0";><blogname
jcr:primaryType="nt:unstructured" firstName="Roberta" lastName="Chambers"
seq="
105" sling:resourceType="mjb/blog"/><blogname_0
jcr:primaryType="nt:unstructured" firstName="Roberta" lastName="Chambers"
seq="105" sling:resourceType
="mjb/blog"/></blog>


[1].
http://sling.apache.org/site/manipulating-content-the-slingpostservlet-servletspost.html#ManipulatingContent-TheSlingPostServlet%2528servlets.post%2529-AlgorithmforNodeNameCreation


On Wed, Jul 28, 2010 at 10:59 AM, Tony Giaccone <[email protected]> wrote:

>
>
>
> So here's my problem.  I have a customer, and the customer has potentially
> many orders.  I want the orders to be stored as documents of "type" Order.
> And I want them to be stored uniquely, and I'm willing to use the Sling
> wildcard as part of the insertion, so that each order is unique in the
> repository.
>
> So you can imagine that my insert URL's look like
>
>
> http://repository.ourcompany.com/DocumentRepository/Orders/{CustomerID}/Orders/*<http://repository.ourcompany.com/DocumentRepository/Orders/%7BCustomerID%7D/Orders/*>
>
> This all works fine and I end up with this kind of deal...
>
> Orders/11_1280339300849
> Orders/12_1280339533384
> Orders/13_1280339543556
>
>
> And that is fine, I totally understand that as the result and it makes
> perfect sense, however,
>
> when I hit this URL
>
>
> http://repository.ourcompany.com/DocumentRepository/Orders/{CustomerID}/Orders/12_1280339533384.xml<http://repository.ourcompany.com/DocumentRepository/Orders/%7BCustomerID%7D/Orders/12_1280339533384.xml>
>
> I get xml that starts out with:
>
> <_x0031_2_1280339533384 ...
>
>
> What I need is for that tag to be:
>
> <order orderId="12_1280339533384"
>
> If I use a :nameHint then all the documents I insert end up with the same
> name and write over each other.  What I want is uniqueness going in,
> but on a  get, use a value from a field in the document, to render the main
> tag and and identifier  for the xml.
>
> I'm not sure how to make that happen.
>
>
>
> Tony
>
>

Reply via email to