jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From woolly <p.b...@lbs-ltd.com>
Subject Re: Importing and Exporting XML
Date Thu, 14 Jun 2007 13:06:57 GMT

Hi there,

I've got a hold of DocumentViewExportVisitor from the contrib section as
suggested, and added the jar files xercesImpl-2.8.1.jar and
commons-codec-1.3.jar that it appeared to require. I then subclassed
DocumentViewExportVisitor like this:

public class CleanDocumentViewExportVisitor extends
DocumentViewExportVisitor
{
	
	public CleanDocumentViewExportVisitor(ContentHandler handler, boolean
skipBinary, boolean noRecurse)
	{
		super(handler, skipBinary, noRecurse);
	}
	
	@Override
	protected boolean includeProperty(Property property) throws
RepositoryException
	{
		return !property.getName().startsWith("jcr:");
	}
}

.....and exported my document using this:

SAXTransformerFactory factory = (SAXTransformerFactory)
SAXTransformerFactory.newInstance();
TransformerHandler handler = factory.newTransformerHandler();
handler.setResult(new StreamResult(output));
node.accept(new CleanDocumentViewExportVisitor(handler, skipBinary,
noRecurse));

....but I end up with the following (based on my original <cheeses>
example):

<?xml version="1.0" encoding="UTF-8"?>
<cheeses xmlns:dc="http://www.purl.org/dc/elements/1.1/"
xmlns:jcr="http://www.jcp.org/jcr/1.0"
xmlns:nt="http://www.jcp.org/jcr/nt/1.0"
xmlns:sv="http://www.jcp.org/jcr/sv/1.0"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:fn="http://www.w3.org/2005/xpath-functions"
xmlns:fn_old="http://www.w3.org/2004/10/xpath-functions"
xmlns:mix="http://www.jcp.org/jcr/mix/1.0" xmlns:rep="internal">
    <cheese>edam</cheese>
    <cheese>lancashire</cheese>
    <cheese>cheshire</cheese>
    <cheese>stilton</cheese>
</cheeses>

Why does JCR need to add all these namespaces to my root node on export?
They're not shown as properties when they are stored in the repository, and
I can't affect them as they are never passed through includeProperty().

Thanks

Phil.


Alessandro Bologna wrote:
> 
> Jukka,
> 
> yes no problems. I will file it as a bug. And yes, I think that  
> exportVisitor, providing a simple way to customize the XML  
> presentation of a JCR subtree is quite useful for a RESTful XSLT  
> presentation layer of a JCR. In fact, that's why I use it.
> 
> Alessandro
> 
> 
>   On Jun 13, 2007, at 9:25 AM, Jukka Zitting wrote:
> 
>> Hi,
>>
>> On 6/13/07, Alessandro Bologna <alessandro.bologna@gmail.com> wrote:
>>> Just be sure to fix the line in escapeName(), otherwise you will not
>>> like the document that much...
>>>
>>>         >if ((i == 0) ? XMLChar.isNCNameStart(ch) :  
>>> XMLChar.isNCName(ch)) {
>>>         <if ((i == 0) ? !XMLChar.isNCNameStart(ch) : ! 
>>> XMLChar.isNCName(ch)) {
>>>
>>> The test should be with a not (!).
>>> I forgot to mention that in my previous reply, and maybe the project
>>> owner can fix it?
>>
>> Sure, thanks for catching that! Could you file a a bug report for  
>> that?
>>
>> If there's interest in the ExportVisitor functionality, we could make
>> it available in jackrabbit-jcr-commons in the 1.4 release.
>>
>> BR,
>>
>> Jukka Zitting
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Importing-and-Exporting-XML-tf3908819.html#a11119815
Sent from the Jackrabbit - Users mailing list archive at Nabble.com.


Mime
View raw message