If I have a <desc> element, I should be able to set and get the xml:space attribute using

String space = desc.getAttributeNS( XMLConstants.XML_NAMESPACE_URI, "space" );
and
desc.setAttributeNS( XMLConstants.XML_NAMESPACE_URI, "space", "preserve" );


However, I'm getting some unexpected behaviour when I write my document to a file and read it back in. Having set the xml:space attribute as above, the SVG document contains
<desc space="preserve">blah</desc>
This is incorrect: the "xml:" namespace prefix is missing from the space attribute.


If instead I use the following incorrect code:
   desc.setAttributeNS( null, "xml:space", "preserve" );
then the output file is written correctly.

This odd behaviour seems to happen only with some namespaced-attributes, not all. The two I've noticed are xml:space and xlink:href, and these show problems only intermittently. Is this a bug in Batik's DOM? (I'm using v1.5.1.) Or have I omitted something?

I noticed there has been a related bug filed;
http://issues.apache.org/bugzilla/show_bug.cgi?id=20156

Regards,
Rick


Here's a more complete exceprt of my test code

public void addContent ()
{
SVGOMDocument document = (SVGOMDocument) getDocument();
Element svg = document.getDocumentElement();
SVGDOMImplementation impl = (SVGDOMImplementation)
SVGDOMImplementation.getDOMImplementation();
Element defs = impl.createElementNS( document,
SVGDOMImplementation.SVG_NAMESPACE_URI, SVGConstants.SVG_DEFS_TAG );
defs.setAttributeNS( null, "id", "defs1" );
svg.appendChild( defs );


Element desc = impl.createElementNS( document,
SVGDOMImplementation.SVG_NAMESPACE_URI, SVGConstants.SVG_DESC_TAG );
GenericText t1 = new GenericText( "two line\ndescription", document );
desc.appendChild( t1 );
desc.setAttributeNS( null, "id", "desc1" );
desc.setAttributeNS( XMLConstants.XML_NAMESPACE_URI, "space", "preserve" );
svg.appendChild( desc );


Element a = impl.createElementNS( document,
SVGDOMImplementation.SVG_NAMESPACE_URI, SVGConstants.SVG_A_TAG );
GenericText t2 = new GenericText( "hello", document );
a.appendChild( t2 );
a.setAttribute( "id", "a1" );
a.setAttributeNS( XMLConstants.XLINK_NAMESPACE_URI, "href", "nowhere" );
a.setAttributeNS( XMLConstants.XLINK_NAMESPACE_URI, "type", "simple" );
svg.appendChild( a );
}



--

Visit our website at www.roke.co.uk

Roke Manor Research Ltd, Roke Manor, Romsey, Hampshire SO51 0ZN, UK.

The information contained in this e-mail and any attachments is confidential to
Roke Manor Research Ltd and must not be passed to any third party without
permission. This communication is for information only and shall not create or
change any contractual relationship.


--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to