[jdom-interest] Adding attributes with XPath

Dmitriy Viner dxv7027 at yahoo.com
Thu Jul 28 11:38:15 PDT 2005


Is it possible to add attributes with xpath expression?

jdom-interest-request at jdom.org wrote:Send jdom-interest mailing list submissions to
jdom-interest at jdom.org

To subscribe or unsubscribe via the World Wide Web, visit
http://www.jdom.org/mailman/listinfo/jdom-interest
or, via email, send a message with subject or body 'help' to
jdom-interest-request at jdom.org

You can reach the person managing the list at
jdom-interest-owner at jdom.org

When replying, please edit your Subject line so it is more specific
than "Re: Contents of jdom-interest digest..."


Today's Topics:

1. making XMLOutputter DTD-aware (Paul Libbrecht)
2. XMLOutputter generates weird chars (Ivo J?nsk?)


----------------------------------------------------------------------

Message: 1
Date: Tue, 26 Jul 2005 17:05:40 +0200
From: Paul Libbrecht 

Subject: [jdom-interest] making XMLOutputter DTD-aware
To: jdom-interest at jdom.org
Message-ID: 
Content-Type: text/plain; charset=US-ASCII; format=flowed


hello list,

I gave some cycles into making XMLOutputter DTD-aware.
The reason for doing so is that we write XML-files with a dtd-reference 
with a large set of hidden information encoded in the DTD such as 
namespace for almost all elements. Most of these are attribute default 
values.
Only using such an outputter I can claim that our authors' files are 
not changed too dramatically. Otherwise, each line is made twice as big 
and completely unreadable.

Clearly using a finer-grained parsing (that would report wether an 
attribute is present or only "implied") would bring it all... but such 
fine-grained lexical analysis isn't available as far as I know.

So I just adapted XMLOutputter to prevent the output of attributes of 
namespaces if equivalent to the DTD-specified values... seems to be 
working fine.

I'd love providing this to the project. It is relying on Mark Wutka's 
DTD parser, now with an Apache-style-license, which is the only usable 
DTD-parser I found.
Where could I drop such a submission ?

Also I would have wished to subclass XMLOutputter but this turned out 
to be impossible... there are too many private methods that needed to 
be either re-used or overridden... not sure if that's solvable. 
Currently, I just added "setDtd" and modified XMLOuputter's methods 
directly.

paul



------------------------------

Message: 2
Date: Tue, 26 Jul 2005 18:48:31 +0200
From: Ivo J?nsk? 

Subject: [jdom-interest] XMLOutputter generates weird chars
To: jdom-interest at jdom.org
Message-ID: <200507261848.32113.linux4life at seznam.cz>
Content-Type: text/plain; charset="us-ascii"

Hi,

when I run the following code:

//in the xml variable (java.lang.String) is the actual XML code

SAXBuilder builder = new SAXBuilder("org.apache.xerces.parsers.SAXParser", false);
Document document = builder.build(new ByteArrayInputStream(xml.toBytes()));

Format format = Format.getPrettyFormat();
XMLOutputter fmt = new XMLOutputter(format);
xml = fmt.outputString(document);
System.out.println(xml);

I see this in the console:







http://service.ariba.com/cgi/orders.cgi


http://service.ariba.com/cgi/PunchOut.cgi






but I should see this:







http://service.ariba.com/cgi/orders.cgi


http://service.ariba.com/cgi/PunchOut.cgi






the difference?
a-dtype=... should not be there

I just can't figure out what is wrong. Any ideas?


------------------------------

_______________________________________________
To control your jdom-interest membership:
http://www.jdom.org/mailman/options/jdom-interest/youraddr@yourhost.com

End of jdom-interest Digest, Vol 12, Issue 10
*********************************************




Sincerely Dmitriy Viner

E-Mail: dxv7027 at yahoo.com

Cell Phone: 716-415-3096

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.jdom.org/pipermail/jdom-interest/attachments/20050728/0de739fa/attachment.htm


More information about the jdom-interest mailing list