It just doesn't make sense to me to take an object (a "document"),
create an XML representation of that object, and then store the
representation in the repository as a single node (or node property).

If you have:
>       <document>
>               <name>
>                       <firstName>Bob</firstName>
>                       <lastName>Smith</lastname>
>               </name>
>       </document>

and currently you're storing the document as /documents/doc1, then

/documents/doc1/n...@firstname = Bob
/documents/doc1/n...@lastname = Smith

i.e. doc1 has a child node called name which has attributes named
firstName and lastName.

If you store XML in the repository and then want to access the values
inside that document in a script, you'll need to parse the document into
a DOM of some sort.

Justin




On 5/24/10 12:51 PM, Tony Giaccone wrote:
> 
> 
> Maybe it makes better sense to talk about the general form of the application 
> and a bit of the code. 
> 
> 
> Here's the java code that posts a document into the repository.  It takes the 
> document and creates an XML representation of that document. 
> 
> Extracts some metadata (these are in general things we will search on). 
> 
> And then inserts the metadata and the xml using a PUT into the repository. 
> 
>               String documentXML = data.toXML();
>               String repoBin =  
> repoManager.documentToPath(data,data.SLING_RESOURCE_TYPE);
>               String postMethodURL = 
> repoURLPut+repoBin+"/"+data.getDocumentId();
>               log.debug("url ->" + postMethodURL);
>           PostMethod post = new PostMethod(postMethodURL);
>           NameValuePair[] formData = { 
>                   new NameValuePair(RESOURCE_ID, 
> Warrant.SLING_RESOURCE_TYPE), 
>                   new NameValuePair(DOC_TITLE, data.getWarrantId()),
>                   new NameValuePair(DOCUMENT_ID, data.getCaseId()),
>                   new NameValuePair(DOCUMENT_XML, warrantXML)
>                  };
>           
>           post.setRequestBody(formData); 
>               String response = null;
>               int status;
>               try {
>                       status = client.executeMethod( post );
> 
> 
> I didn't include all the code for handling the response as I don't think it's 
> relevant here. 
> 
> 
> Question #1. Does that seem like a reasonable way to put an XML document that 
> is probably only going to be a 20 or 30 thousand bytes (maybe smaller) into 
> the repository?
> 
> If not, how would you insert it?
> 
> 
> Question #2  Now I've got data in my repository? How do I reference the 
> values in that XML in a JSP. Suppose for simplicity sake my document was:
>       <document> 
>               <name>
>                       <firstName>Bob</firstName>
>                       <lastName>Smith</lastname>
>               </name>
>       </document> 
> 
> How would I go about putting that name on to a JSP?  
> 
> 
> What if it was:
> 
> 
>       <document>
>               <names> 
>                       <name>
>                               <firstName>Bob</firstName>
>                               <lastName>Smith</lastname>
>                       </name>
>                       <name>
>                               <firstName>Bill</firstName>
>                               <lastName>Jones</lastname>
>                       </name> 
>               </names>
>       </document> 
> 
> 
> Looking for some basic answers. 
> 
> 
> Tony Giaccone
> 

Reply via email to