jackrabbit-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jukka Zitting (JIRA)" <j...@apache.org>
Subject [jira] Commented: (JCR-1952) DOMException: NAMESPACE_ERR thrown when exporting document view
Date Sun, 15 Feb 2009 09:57:02 GMT

    [ https://issues.apache.org/jira/browse/JCR-1952?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12673583#action_12673583

Jukka Zitting commented on JCR-1952:

This is a pretty tricky issue.

The reason why Jackrabbit adds those extra xmlns attributes is that at least the default XML
serializer in Sun Java 1.4 does not include xmlns settings in the serialized XML stream without
those attributes (even if the correct startPrefixMapping() calls are made and the namespaces
used in the exported elements). Unfortunately it seems like some serializers will add their
own xmns attributes regardless of whether they already exist for an element, causing duplicate
namespace declarations to occur.

We could (and should) use the new SerializingContentHandler class also for the XML export
methods (curiously that seems to be the only XML serialization case where we *don't* yet use
the new class) to automatically add the extra xmlns attributes only when they really are needed.
This would solve the problem of duplicate xmlns attributes.

However, many XML serializers that do output the needed xmlns attributes, only do so for namespaces
that are actually referenced in the serialized elements. This is troublesome for JCR, where
XML exports are always required to contain *all* registered namespaces even when the exported
subtree doesn't reference them. I consider this a flaw in the JCR spec, but we still need
to honor this requirement and make sure that all the xmlns attributes are included in the
serialized output.

I guess we need to extend the SerializingContentHnalder even more to detect the case when
it needs to inject xmlns attributes only for unused namespaces.

> DOMException: NAMESPACE_ERR thrown when exporting document view
> ---------------------------------------------------------------
>                 Key: JCR-1952
>                 URL: https://issues.apache.org/jira/browse/JCR-1952
>             Project: Jackrabbit Content Repository
>          Issue Type: Bug
>          Components: xml
>    Affects Versions: 1.5.2
>            Reporter: Lóránt Pintér
>         Attachments: MANIFEST.MF
> When I try to export some nodes with ExportDocumentView I get a DOMException with Jackrabbit
1.5.2. Version 1.4.6 works fine. Xerces version was 2.8.1.
> Code:
> Document document = documentBuilder.newDocument();
> Element exportElement = (Element) document.appendChild(document.createElement("Export"));
> Result result = new DOMResult(exportElement);
> TransformerHandler transformerHandler = saxTransformerFactory.newTransformerHandler();
> transformerHandler.setResult(result);
> session.exportDocumentView(workflowNode.getPath(), transformerHandler, true, false);
> Exception:
> org.w3c.dom.DOMException: NAMESPACE_ERR: An attempt is made to create or change an object
in a way which is incorrect with regard to namespaces.
> 	at org.apache.xerces.dom.CoreDocumentImpl.checkDOMNSErr(Unknown Source)
> 	at org.apache.xerces.dom.AttrNSImpl.setName(Unknown Source)
> 	at org.apache.xerces.dom.AttrNSImpl.<init>(Unknown Source)
> 	at org.apache.xerces.dom.CoreDocumentImpl.createAttributeNS(Unknown Source)
> 	at org.apache.xerces.dom.ElementImpl.setAttributeNS(Unknown Source)
> 	at com.sun.org.apache.xalan.internal.xsltc.trax.SAX2DOM.startElement(SAX2DOM.java:194)
> 	at com.sun.org.apache.xml.internal.serializer.ToXMLSAXHandler.closeStartTag(ToXMLSAXHandler.java:204)
> 	at com.sun.org.apache.xml.internal.serializer.ToSAXHandler.flushPending(ToSAXHandler.java:277)
> 	at com.sun.org.apache.xml.internal.serializer.ToXMLSAXHandler.startElement(ToXMLSAXHandler.java:646)
> 	at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerHandlerImpl.startElement(TransformerHandlerImpl.java:263)
> 	at org.apache.jackrabbit.commons.xml.Exporter.startElement(Exporter.java:438)
> 	at org.apache.jackrabbit.commons.xml.DocumentViewExporter.exportNode(DocumentViewExporter.java:76)
> 	at org.apache.jackrabbit.commons.xml.Exporter.exportNode(Exporter.java:298)
> 	at org.apache.jackrabbit.commons.xml.Exporter.exportNodes(Exporter.java:214)
> 	at org.apache.jackrabbit.commons.xml.DocumentViewExporter.exportNode(DocumentViewExporter.java:77)
> 	at org.apache.jackrabbit.commons.xml.Exporter.exportNode(Exporter.java:295)
> 	at org.apache.jackrabbit.commons.xml.Exporter.export(Exporter.java:144)
> 	at org.apache.jackrabbit.commons.AbstractSession.export(AbstractSession.java:461)
> 	at org.apache.jackrabbit.commons.AbstractSession.exportDocumentView(AbstractSession.java:241)

This message is automatically generated by JIRA.
You can reply to this email to add a comment to the issue online.

View raw message