Alessandro Bologna wrote:
>
> Phil,
>
> it looks a bit better already...
> Those namespace are there because they are added in with
> handler.StartPrefixMapping() in the visit method, and they are needed
> because the method is generic, and all it does is to add all the
> namespaces
> that are declared in the current repository (some of those that you list
> are
> not really jcr related and I suspect that were added when you imported
> other
> XML documents into it).
>
Does JackRabbit store the namespaces related to each node, or are they
stored in some general location? If they are stored with the node then I may
be able to write something to find all the namespaces required for a certain
branch when I export from that node......?
> The namespace declaration is not an attribute, and that's why you cannot
> remove them in the includeProperty method.
>
> I am sure that there could be other ways too, but one solution is to use a
> processing chain on the output (SAX transformers are really meant for
> that)
>
Sorry, what do you mean by a processing chain? I'm more of a DOM kind-a-guy
usually....
> and use this XSLT to strip all the namespaces:
>
> <xsl:template match="*">
> <xsl:element name="{local-name()}" namespace="">
> <xsl:copy-of select="@*"/>
> <xsl:apply-templates />
> </xsl:element>
> </xsl:template>
>
> Alessandro
>
>
>
>
>
>
> On 6/14/07, woolly <[EMAIL PROTECTED]> wrote:
>>
>>
>> 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 <[EMAIL PROTECTED]> 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.
>>
>>
>
>
--
View this message in context:
http://www.nabble.com/Importing-and-Exporting-XML-tf3908819.html#a11123015
Sent from the Jackrabbit - Users mailing list archive at Nabble.com.