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