[jdom-interest] Re: jdom-interest digest, Vol 1 #745 - 23 msgs

Peter.H.Roberts at bbh.com Peter.H.Roberts at bbh.com
Thu Oct 25 08:42:50 PDT 2001


In answer to the Save question:-

static public void outputToFileSystem(Document xmlDoc,
                                          String filename,
                                          boolean addSpace,
                                          boolean debug)
        throws java.lang.Exception
{
  XMLOutputter outputter = null;
  if (addSpace)
   outputter = new XMLOutputter("  ", true );
  else
   outputter = new XMLOutputter();
  if (debug) {
   // Display to vaj console
     outputter.output( xmlDoc, System.out );
  }
     FileOutputStream outF = new FileOutputStream( filename );
     outputter.output( xmlDoc, outF );
     outF.close();
}

where filename is :-
D:\LiteReporting\ActionWorld\NJ88025\UnconfActionResearch.Filter.xml

hope this helps

Peter:)



                                                                                                                               
                    jdom-interest-admi                                                                                         
                    n at jdom.org               To:     jdom-interest at jdom.org                                                    
                                             cc:                                                                               
                    10/25/2001 02:04         Subject:     jdom-interest digest, Vol 1 #745 - 23 msgs                           
                    AM                                                                                                         
                    Please respond to                                                                                          
                    jdom-interest                                                                                              
                                                                                                                               
                                                                                                                               




Send jdom-interest mailing list submissions to
     jdom-interest at jdom.org

To subscribe or unsubscribe via the World Wide Web, visit
     http://lists.denveronline.net/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-admin 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. RE: Problem with DocType when converting JDOM Doc
       ument  to (JAXP) W3CDocument (Bilton, Sasha)
   2. Save (sai reddy)
   3. RE: interface q (but not the usual one) (rpcee)
   4. Re: Save (Christian Knorr)
   5. jdom b7 XMLSchema validation (Neil Blue)
   6. Re: jdom b7 XMLSchema validation (dfeather at oreillyauto.com)
   7. RE: Text class in the api (Alex Rosen)
   8. RE: Text class in the api (Alex Rosen)
   9. Re: Problem with DocType when converting JDOM Document
       to (JAXP) W3CDocument (Jason Hunter)
  10. converting from DOM elements to JDOM elements (Leon C. Webster)
  11. setting SAXParser properties? (Travers Waker)
  12. DTD not found (Stefanie de Koster)
  13. Keeping newlines in attribute values (Christian Hirsch)
  14. Re: setting SAXParser properties? (Jason Hunter)
  15. Re: converting from DOM elements to JDOM elements (Jason Hunter)
  16. RE: setting SAXParser properties? (Alex Rosen)
  17. In a fit of madness... (Neil Blue)
  18. factory helper (rpcee)
  19. Re: Keeping newlines in attribute values (Jason Hunter)
  20. JDOM Xerces and Xalan versions (Joel P. Worrall)
  21. RE: JDOM Xerces and Xalan versions (Joel P. Worrall)

--__--__--

Message: 1
From: "Bilton, Sasha" <Sasha.Bilton at bskyb.com>
To: "'jdom-interest at jdom.org'" <jdom-interest at jdom.org>
Subject: RE: [jdom-interest] Problem with DocType when converting JDOM Doc
     ument  to (JAXP) W3CDocument
Date: Wed, 24 Oct 2001 09:22:48 +0100


> -----Original Message-----
> From: Jason Hunter [mailto:jhunter at acm.org]
>
> JAXP is a little library that automatically select a parser for you
> based on system properties.  There's no such thing as a "JAXP
> Document".  Thus I don't understand your question.

Sorry my mistake, I have a annoying habit of say JAXP when I mean W3C.

When we convert,using DOMOutputter, our org.jdom.Document to
org.w3c.dom.Document (from Crimson.jar) we lose the Doctype information.

The original jdom.Documnet.getDocType() returns a valid DocType object, but
we don't see it in the w3c.Document

It would be easy enough to add the Doctype to the w3c object, but not very
elegant.

Has anyone else seen this?


**********************************************************************
Information in this email is confidential and may be privileged.
It is intended for the addressee only. If you have received it in error,
please notify the sender immediately and delete it from your system.
You should not otherwise copy it, retransmit it or use or disclose its
contents to anyone.
Thank you for your co-operation.
**********************************************************************


--__--__--

Message: 2
From: "sai reddy" <saireddy at hotmail.com>
To: jdom-interest at jdom.org
Date: Wed, 24 Oct 2001 08:42:11 +0000
Subject: [jdom-interest] Save

Hello,
  I have created an xml file using the jdom. But now I want to save the xml
file in an already existing xml file if the user has made any changes.
How can I do this.

Thanks.

REg,
sai

_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp


--__--__--

Message: 3
Date: Wed, 24 Oct 2001 05:06:58 -0400
From: rpcee <rpcee at operamail.com>
To: jdom-interest <jdom-interest at jdom.org>, philip.nelson at omniresources.com
Subject: RE: [jdom-interest] interface q (but not the usual one)

>> I also
>> have a requirement to treat some proprietary structures as
>> XML (it's a simple
>> mapping); I guess I would be unable to make JDOM the common
>> API because the
>> interface and implementation are not separated(?) Is there another
>> possibility, other than using DOM or a home grown interface?
>
>Not sure what you mean here.

What I would like is:
  an interface called say IElement which contains all (or relevant) public
methods in org.jdom.Element, possibly same for Attribute etc
  org.jdom.Element or a subclass thereof to implement that interface.

then I can have other proprietary classes implement IElement, and have common
code to manipulate both JDOM and other structures, eg:

  public void doSomethingWith(IElement anElement)
  {
    List children = anElement.getChildren();
    // do other JDOM like things on anElement
  }

I'm not interested in using for example JDOM serialisation etc (except for
concrete JDOM classes), so I don't think I'm looking for any fundamental
change to JDOM. I guess I can subclass Element and use factories to do this?
I've just got Brett's book, so maybe I'll find some time to read it.

I'm not trying to open the old interfaces debate:) I still want the concrete
classes and constructors etc. I'd just like to have code that works with JDOM
able to work with some other stuff too.

Thanks, Richard


--__--__--

Message: 4
From: Christian Knorr <christian.knorr at gmx.de>
To: sai reddy <saireddy at hotmail.com>
Cc: jdom-interest at jdom.org
Date: Wed, 24 Oct 2001 11:12:25 +0200
Subject: Re: [jdom-interest] Save

Use org.jdom.XMLOutputter which provides several methods for outputting
jdom objects (Document, Element etc.) to a java.io.Writer,
java.io.OutputStream or others.

Christian

sai reddy wrote:
>
> Hello,
>   I have created an xml file using the jdom. But now I want to save the xml
> file in an already existing xml file if the user has made any changes.
> How can I do this.
>
> Thanks.
>
> REg,
> sai
>
> _________________________________________________________________
> Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp
>
> _______________________________________________
> To control your jdom-interest membership:
> http://lists.denveronline.net/mailman/options/jdom-interest/youraddr@yourhost.com

--__--__--

Message: 5
Date: Wed, 24 Oct 2001 11:38:09 +0100
From: Neil Blue <neil.blue at denovopharma.com>
To: jdom-interest <jdom-interest at jdom.org>
Subject: [jdom-interest] jdom b7 XMLSchema validation


--------------010409060202080600010006
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit

Hello,

I am trying to use XMLSchema validation with JDom b7
I have set up my files as:

contents.xml

<?xml version="1.0"?>
<Book
 xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"
<http://www.w3.org/1999/XMLSchema-instance>
 xsi:noNamespaceSchemaLocation="http://cerverous/myschema.xsd"
<http://cerverous/myschema.xsd>>
 <title>Test string</title>
</Book>

where 'http://cerverous/' is the location of the schema definition file
and my schema as myschema.xsd:


<?xml version="1.0"?>
<schema xmlns="http://www.w3c.org/1999/XMLSchema"
<http://www.w3c.org/1999/XMLSchema>>
 <element name="Book" type="BookType">
 <complexType name="BookType">
  <element name="title" type="string">
 </complexType>
</schema>


However I consistently get the error:

org.jdom.JDOMException: Error on line 2 of document
file:/home/neil/jdom/samples/contents.xml:
<cid:part1.09070300.01080109 at netscape.com> Element type "Book" is not
declared.
  at org.jdom.input.SAXBuilder.build(SAXBuilder.java:296)
  at org.jdom.input.SAXBuilder.build(SAXBuilder.java:682)
...

Cheers
Neil

--------------010409060202080600010006--


--__--__--

Message: 6
From: dfeather at oreillyauto.com
To: jdom-interest <jdom-interest at jdom.org>
Subject: Re: [jdom-interest] jdom b7 XMLSchema validation
Date: Wed, 24 Oct 2001 08:26:22 -0500

Neil,

I think the problem is the namespace URI you are using. The new versions
of Xerces (I am assuming you are using Xerces) only does schema validation
for the new Schema Specs. So you need to change the URI to
"http://www.w3.org/2001/XMLSchema" for your schemas and
"http://www.w3.org/2001/XMLSchema-instance" for your documents. I had the
same problem until I did that. I hope this fixes your problem.

Dan
dfeather at oreillyauto.com




--__--__--

Message: 7
From: "Alex Rosen" <arosen at silverstream.com>
To: <philip.nelson at omniresources.com>, <hip at a.cs.okstate.edu>,
        <jdom-interest at jdom.org>
Subject: RE: [jdom-interest] Text class in the api
Date: Wed, 24 Oct 2001 10:52:26 -0400

> > One thing is I remember a post about not wanting to force
> > anyone to use
> > Text class if they didn't want to, I however think it should be one
> > way or the other, either Element.content has only Text or
> > only String for
> > textual content, but not both.
>
> The intent was to keep all the String based methods.  These
> strings would be
> kept in the content List of Element inside Text objects.  We
> would provide
> methods to directly add Text nodes to an element's content
> and inside the
> list, there would not be any Strings.

I'd say this a little differently - an Element has Text nodes, not String
nodes. But we will keep the convenience methods that can return the
Element's value as a String, concatenating all the characters from all its
Text nodes together. So get*Text*() and setText() stay, but
addContent(String) and removeContent(String) are replaced by Text versions.

Alex


--__--__--

Message: 8
From: "Alex Rosen" <arosen at silverstream.com>
To: <philip.nelson at omniresources.com>, <jdom-interest at jdom.org>
Subject: RE: [jdom-interest] Text class in the api
Date: Wed, 24 Oct 2001 11:07:15 -0400

> I am *theorizing* that if Text was based on char[], append
> would work as
> well as StringBuffer, possibly faster because we wouldn't have to have
> syncronized methods.  Marginal difference quite possibly.
> StringBuffer
> doesn't have a constructor for char[], int, int, unlike
> String. In the most
> common case where the full text content of an element arrives in one
> characters() call, a char[] implementation wouldn't have to
> allocate extra
> space, which I think StringBuffer does by default.  If we
> want to allocate
> extra space, this could be set as a property or in a resource bundle.
> toString() would be about the same as StringBuffer most likely.

Isn't that char[] the internal buffer of the parser, that gets reused? If
so, then there needs to be an allocation and copy, whether this gets done
internally by String(char[]) or StringBuffer.append(char[]), or we do it
manually. The comment about synchronization is a good one, but supposedly
the penalty for sychronized methods is negligible with HotSpot. Doesn't seem
worth it to basically rewrite StringBuffer inside of Text.

> Thinking about this, is seems that if we took the existing
> starter code,
> based on StringBuffer, added append and constructor
> signatures that accepted
> char[], int, int, we could modify it further down the road.
> Might get us there faster.

That sounds like the right approach to me.

Alex


--__--__--

Message: 9
Date: Wed, 24 Oct 2001 08:40:56 -0700
From: Jason Hunter <jhunter at servlets.com>
To: JDOM Interest <jdom-interest at jdom.org>
Subject: Re: [jdom-interest] Problem with DocType when converting JDOM Document
 to (JAXP) W3CDocument

"Bilton, Sasha" wrote:
>
> > -----Original Message-----
> > From: Jason Hunter [mailto:jhunter at acm.org]
> >
> > JAXP is a little library that automatically select a parser for you
> > based on system properties.  There's no such thing as a "JAXP
> > Document".  Thus I don't understand your question.
>
> Sorry my mistake, I have a annoying habit of say JAXP when I mean W3C.
>
> When we convert,using DOMOutputter, our org.jdom.Document to
> org.w3c.dom.Document (from Crimson.jar) we lose the Doctype information.
>
> The original jdom.Documnet.getDocType() returns a valid DocType object, but
> we don't see it in the w3c.Document

Well, if you look at the code for DOMOutputter there is code to set it.

            // Assign DOCTYPE during construction
            DocType dt = document.getDocType();
            domDoc = createDOMDocument(dt);

Are you using the beta7 or later?  Make sure you are.  If it's still not
working, you have the code so you can do a little debugging on why that
setting above isn't working for you.  Let us know what you find.

-jh-

--__--__--

Message: 10
From: "Leon C. Webster" <leon at visi.com>
To: jdom-interest at jdom.org
Date: Tue, 23 Oct 2001 13:56:45 GMT
Subject: [jdom-interest] converting from DOM elements to JDOM elements

We have a small application that we want to migrate to JDOM.  It uses XML
messages to communicate between some JSP/Servlets on the one hand and a set
of business operations in the "back end".  When these business operations
receive a message, it is handed to a class parses message and constructs
various domain objects from each of the 1st level children in the message.
Right now, these domain objects have a constructor that takes a DOM Element.
We will change that so the constructor takes an JDOM element.

The only problem is that one of the domain objects has a very complex
constructor, and we would like to put off converting that to JDOM for a
while.  So, my question is, is there a way to get the original DOM node or
element from a JDOM element?

Thanks much.

Leon Webster

--__--__--

Message: 11
From: "Travers Waker" <traversw at innoforge.com>
To: <jdom-interest at jdom.org>
Date: Wed, 24 Oct 2001 12:28:04 +0200
Subject: [jdom-interest] setting SAXParser properties?

Hi everyone.

The Xerces documentation says the following:

<XercesDoc>

To set a property on either org.apache.xerces.parsers.SAXParser or org.apache.xerces.parsers.DOMParser, you should use the
SAX2 method setProperty(String,Object). To query a property, use the SAX2 method getProperty(String).

For example, to set the document factory by name:

DOMParser p=new DOMParser();
try

  p.setProperty("http://apache.org/xml/properties/dom/document-class-name",
                "org.apache.xerces.dom.DocumentImpl");
} catch (SAXException e) {
  System.out.println("error in setting up parser property");
}

</XercesDoc>

Can I do this from JDOM?  I can't see a method in SAXBuilder that gives me access to the underlying SAXParser.

Thanks for any help.

Travers



--__--__--

Message: 12
From: Stefanie de Koster <stefanie.dekoster.az at vodafone-telecommerce.de>
To: "'jdom-interest at jdom.org'" <jdom-interest at jdom.org>
Date: Wed, 24 Oct 2001 14:09:13 +0200
Subject: [jdom-interest] DTD not found

Hey,

I want to have a DOMTree from a file. My problem is that the DTD is not find.
I tried several doctype-statements but neither work:
<!DOCTYPE buch SYSTEM "test.dtd">
<!DOCTYPE buch SYSTEM "./test.dtd">
<!DOCTYPE buch SYSTEM "c:/mdkosst/Eigene Dateien/test.dtd">
My program has to process all these opportunities because I don't know
anything of the XML-file or the DTD.

Need help!

Thanks,
Steffi



---------------------------------------------------------
This Mail has been checked for Viruses
Attention: Encrypted mails can NOT be checked!

**

Diese Mail wurde auf Viren geprueft
Hinweis: Verschluesselte mails koennen NICHT auf Viren geprueft werden!
---------------------------------------------------------


--__--__--

Message: 13
Date: Wed, 24 Oct 2001 14:57:10 +0200 (MET DST)
From: Christian Hirsch <hp at netbook.se>
To: jdom-interest at jdom.org
Subject: [jdom-interest] Keeping newlines in attribute values

Hi.

I need to keep the plain test formatting in longer texts received in
the value of an attribute, but can't figure out how to do so.

Example of an incoming document:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE tst_message SYSTEM "file:/tmp/tst_message.dtd">
<tst_message>
<tst_text
     message="Here are some linesof text I need to know the plain
text fomatting of, that is where the newlines originally
were placed. Especially important in texts like:

2001                   Quite Nice
2000                   Not so Nice
1999                   Ok"
/>
</tst_message>

Where the DTD (file:/tmp/tst_message.dtd) looks like:

<!ELEMENT tst_message  (tst_text) >
<!ELEMENT tst_text     EMPTY >
<!ATTLIST tst_text  message CDATA  #REQUIRED >


So, how do I keep the newlines in the message attribute?

Anyone got any ideas?



Best Regards
Christian Hirsch
------------------------------------------------------
hp at netbook.se                   www.netbook.se
hp at hirsch.pp.se                 www.hirsch.pp.se


--__--__--

Message: 14
Date: Wed, 24 Oct 2001 08:53:22 -0700
From: Jason Hunter <jhunter at servlets.com>
To: Travers Waker <traversw at innoforge.com>
CC: jdom-interest at jdom.org
Subject: Re: [jdom-interest] setting SAXParser properties?

> Can I do this from JDOM?  I can't see a method in SAXBuilder that
> gives me access to the underlying SAXParser.

Try the latest code in CVS.  SAXBuilder has setFeature and setProperty
methods now.

-jh-

--__--__--

Message: 15
Date: Wed, 24 Oct 2001 08:54:20 -0700
From: Jason Hunter <jhunter at servlets.com>
To: "Leon C. Webster" <leon at visi.com>
CC: jdom-interest at jdom.org
Subject: Re: [jdom-interest] converting from DOM elements to JDOM elements

> So, my question is, is there a way to get the original DOM node or
> element from a JDOM element?

There's no "original DOM node" for a JDOM element, but you can use JDOM
to translate back and forth to DOM using DOMOutputter and DOMBuilder.

-jh-

--__--__--

Message: 16
From: "Alex Rosen" <arosen at silverstream.com>
To: "'Travers Waker'" <traversw at innoforge.com>, <jdom-interest at jdom.org>
Subject: RE: [jdom-interest] setting SAXParser properties?
Date: Wed, 24 Oct 2001 11:58:09 -0400

> Can I do this from JDOM?  I can't see a method in SAXBuilder
> that gives me access to the underlying SAXParser.

If you get the latest code from the CVS repository, you'll see a new
setProperty() method. Also, you can always subclass SAXBuilder to configure
the parser however you like.

Alex


--__--__--

Message: 17
Date: Wed, 24 Oct 2001 17:34:44 +0100
From: Neil Blue <neil.blue at denovopharma.com>
To: jdom-interest <jdom-interest at jdom.org>
Subject: [jdom-interest] In a fit of madness...

Hello,

I am now going mad after trying to get XMLSchema validation working.
Here is what I now have:

using:

jdom b7
xerces 2.0 beta 2

The code:

import java.io.*;
import org.jdom.*;
import org.jdom.input.*;
import org.jdom.output.*;

public class SAXBuilderDemo
{
   public static void main( String[] args )
       throws Exception
   {
       SAXBuilder builder = new SAXBuilder( true );
       Document doc = builder.build( "contents.xml" );
       System.err.println( doc );
   }
}

the xml file:

<?xml version="1.0"?>
<Book xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="myschema.xsd">
   <title>Test string</title>
</Book>


the schema file:

<?xml version="1.0"?>
<schema xmlns="http://www.w3c.org/2001/XMLSchema">
   <element name="Book" type="BookType"/>
   <complexType name="BookType">
       <element name="titlex" type="string"/>
   </complexType>
</schema>

but I still get the error when running:

Exception in thread "main" org.jdom.JDOMException: Error in building:
Document root element "Book", must match DOCTYPE root "null".

however if I turn off validation with:

...
       SAXBuilder builder = new SAXBuilder(  );
...

there is no schema validation. Which I would expect as title is defined
as 'titlex' in the schema and 'title' in the xml file.

Does anyone else also have this problem?

Cheers
Neil


--__--__--

Message: 18
Date: Wed, 24 Oct 2001 12:42:40 -0400
From: rpcee <rpcee at operamail.com>
To: jdom <jdom-interest at jdom.org>
Subject: [jdom-interest] factory helper

  This is the preamble of a multipart MIME formatted message.
  If you are reading this text your mail system is most likely
  not capable of properly decoding MIME messages.  To extract
  the contents of this message, save it to a file and then use
  an external MIME decoding utility.

--mime-boundary-interchange-3be14d61
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 7bit

Attached is a little class that makes jdom factories, to save having to write
them. You just specify the subclasses you want to use, eg:

     FactoryMaker fm = new FactoryMaker(MyElement.class);
     fm.setClass(MyAttribute.class);

     SAXBuilder builder = new SAXBuilder();

     builder.setFactory(fm.getFactory());

     String test = "<?xml version='1.0'?><root><child1
att1='fred'><child2>sometext</child2></child1></root>";

     Document doc = builder.build(new StringReader(test));

     XMLOutputter op = new XMLOutputter("   ", true);
     op.output(doc, System.out);

I have only done minimal testing on (only) Element and Attribute subclasses, I
find it handy when messing about with JDOM; maybe production use would use a
proper factory for efficiency.

Currently if the specified subclass doesn't have a particular constructor, the
factory method invokes the JDOM base class constructor and prints a message;
change the invoke() method to change this behaviour.

--mime-boundary-interchange-3be14d61
Content-Type: application/x-zip-compressed; name="FactoryMaker.zip"
Content-disposition: attachment; filename="FactoryMaker.zip"
Content-Transfer-Encoding: BASE64

UEsDBBQAAAAIAAeMWCsazXCkMAQAACkNAAARAAAARmFjdG9yeU1ha2VyLmph
dmGdVk1v2zgQvftXzPYkO4HcPWcLNEhSNMWmLZrcih5ombKYSKSWpOwagf/7
zpCURElRWpSHxKTmDefj8ZGiqpW2oPQufdyqKl1dLMRoSci6sfSh/fLI9ixt
rCgja7dWMrlLNc9LnnnAerVawAru2BMHBp+uv9x9YJlV+gi50riyE3suwXDc
LQfTbLKSGcMNHAquOSFtwUHz/xqh+RbygK24LdTWgMG9yyNkShqrm8yCwB9M
ZtwQFD0SuvWa0tp71iBUg64zN91zbYSS8Hf6FufrxaJuNqXIwCEgxErR68Xz
AnDUWuyZ5fCRmeKO1dAG/A4kP7SryRJTJ2uPoRHsUqxkclPyikuburXzwQyB
LyEurdVi01geMDBamIFdXV8+XLaQaDJjfq2yh2Pd7TGYzkOaKBcYzufCUlWM
GUxnIF+1wq4aIXe3odfYtdbBKx9n3N1IK+zxG89bF6OFADv5LjoS01jBJWx5
zprS9lwkciBFbaOlgcY0rHQ8b/cLyLV3FegVEytZBppMd7vqiM1G+x2ELTy7
a56JXODhoPzLAd29k/c106wCduUoPf78Slwe4HHLiMq2ECYhtnuD7z/gufV+
mi3cL1JhUAozFgGrsJ58nEj7dQr43ZQw4oCI0yJBSoREEcHD/PYC//3Tcabk
cmcLXDs7W3aAHkoDNcx5TwLmu/gRke80U5Z7TgVpU+gkq2uqpQP4J53cK7Ht
Y5prZS4k0jX+eqXqI+bvJ0HFaBwKgeRKwt5/odw1Zbkc1UDk0Kaf7rhN2g1n
zGnEp9Kbn0eRRBVsx0Zz9jRcPg1mIcQ2Bwrkvqm5djslv9GTb+4sRzy1BbNI
07J0jHUdqjXfC9UYf/vkYtfQ/dRTse+ZV4bB1Ue3ltN85oTqxf7F9phB+JnE
JQyek8h0SVr485ji6XQ/bsN9mAwqFAG83FGNXLH+VWxLinQ+sB+d9QkcTlP7
YHAr9ypzaX5kclui7/bkdUpx6l4JE2NXqa5Qvg9eZ0NrCOUfA3j1t2CDv1E6
sC8Zloj3zwOlyT427GWUVdhUOl6I0O6tgP3w2c2l0vfRTEMfPReip8LFVBuR
0mhTBLcuqF4CfBAVq+eEcGLwogBOOxHFNJb3tPX9ro/adyv2/GXzyN2ja6+e
eBJmNfFuyIfBuPPt8l17xc67Q8IxvcP4bKHVwcAD/WMblKLnXps8N0kqMV7v
mBjtzzE9YeJTPxTPBw9KglDF4kX+YlzPophRvYHFkxrrW2SEO8QbuuPWf036
kL+2DCQzFKuJWjnHzGYFJJ/VfZMVvpw3PzNeuzPCsZWwXkMl3IMojuKcblPY
MPzjQpmN1f5pjAD3R2N5lXKtU6S+tKVM3sSVo0v2DZxNyvEZXaK4neFHR3/H
cONM53d25lJZepMJybcXmCDlTCg7cPxiHYN+RrmTbnaS6XgXidT/UEsBAhQA
FAAAAAgAB4xYKxrNcKQwBAAAKQ0AABEAAAAAAAAAAQAgALaBAAAAAEZhY3Rv
cnlNYWtlci5qYXZhUEsFBgAAAAABAAEAPwAAAF8EAAAAAA==
--mime-boundary-interchange-3be14d61--


--__--__--

Message: 19
Date: Wed, 24 Oct 2001 11:17:14 -0700
From: Jason Hunter <jhunter at servlets.com>
To: Christian Hirsch <hp at netbook.se>
CC: jdom-interest at jdom.org
Subject: Re: [jdom-interest] Keeping newlines in attribute values

Sorry, but XML doesn't let you do what you want to do:

http://www.w3.org/TR/REC-xml#AVNormalize

-jh-

Christian Hirsch wrote:
>
> Hi.
>
> I need to keep the plain test formatting in longer texts received in
> the value of an attribute, but can't figure out how to do so.
>
> Example of an incoming document:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <!DOCTYPE tst_message SYSTEM "file:/tmp/tst_message.dtd">
> <tst_message>
> <tst_text
>         message="Here are some linesof text I need to know the plain
> text fomatting of, that is where the newlines originally
> were placed. Especially important in texts like:
>
> 2001                   Quite Nice
> 2000                   Not so Nice
> 1999                   Ok"
> />
> </tst_message>
>
> Where the DTD (file:/tmp/tst_message.dtd) looks like:
>
> <!ELEMENT tst_message  (tst_text) >
> <!ELEMENT tst_text     EMPTY >
> <!ATTLIST tst_text  message CDATA  #REQUIRED >
>
> So, how do I keep the newlines in the message attribute?
>
> Anyone got any ideas?
>
> Best Regards
> Christian Hirsch
> ------------------------------------------------------
> hp at netbook.se                   www.netbook.se
> hp at hirsch.pp.se                 www.hirsch.pp.se
>
> _______________________________________________
> To control your jdom-interest membership:
> http://lists.denveronline.net/mailman/options/jdom-interest/youraddr@yourhost.com

--__--__--

Message: 20
Reply-To: <jworrall at commnav.com>
From: "Joel P. Worrall" <jworrall at commnav.com>
To: <jdom-interest at jdom.org>
Date: Wed, 24 Oct 2001 15:53:36 -0400
Subject: [jdom-interest] JDOM Xerces and Xalan versions

Greetings:

I am experiencing ClassCastException when attempting to use the JDOM
SAXBuilder with Tomcat 4.0.1 on the JDK 1.4.  It's trying to cast a
SAXParser to an XMLReader (which I have built the source for and know it
implements... very strange)

A couple questions.  Is JDOM capable of working with both those products?

Also, what are the versions of xerces and xalan that ship with jdom7?  Can
they work with the latest of both thsoe projects?

Exception below:

org.jdom.JDOMException: Error in building:
org.apache.xerces.parsers.SAXParser
     at org.jdom.input.SAXBuilder.build(SAXBuilder.java:411)
     at org.jdom.input.SAXBuilder.build(SAXBuilder.java:428)
     at
com.commnav.sbh.framework.config.ServletConfigConfiguration.<init>(ServletCo
nfigConfiguration.java:41)
     at com.commnav.sbh.servlets.ControlServlet.init(ControlServlet.java:90)
     at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:852)
     at
org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:
3267)
     at
org.apache.catalina.core.StandardContext.start(StandardContext.java:3384)
     at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1123)
     at org.apache.catalina.core.StandardHost.start(StandardHost.java:612)
     at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1123)
     at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:307)
     at org.apache.catalina.core.StandardService.start(StandardService.java:388)
     at org.apache.catalina.core.StandardServer.start(StandardServer.java:505)
     at org.apache.catalina.startup.Catalina.start(Catalina.java:776)
     at org.apache.catalina.startup.Catalina.execute(Catalina.java:681)
     at org.apache.catalina.startup.Catalina.process(Catalina.java:179)
     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
     at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:42
)
     at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl
.java:28)
     at java.lang.reflect.Method.invoke(Method.java:313)
     at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:243)
Root cause: java.lang.ClassCastException:
org.apache.xerces.parsers.SAXParser
     at org.jdom.input.SAXBuilder.build(SAXBuilder.java:295)
     at org.jdom.input.SAXBuilder.build(SAXBuilder.java:428)
     at
com.commnav.sbh.framework.config.ServletConfigConfiguration.<init>(ServletCo
nfigConfiguration.java:41)
     at com.commnav.sbh.servlets.ControlServlet.init(ControlServlet.java:90)
     at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:852)
     at
org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:
3267)
     at
org.apache.catalina.core.StandardContext.start(StandardContext.java:3384)
     at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1123)
     at org.apache.catalina.core.StandardHost.start(StandardHost.java:612)
     at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1123)
     at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:307)
     at org.apache.catalina.core.StandardService.start(StandardService.java:388)
     at org.apache.catalina.core.StandardServer.start(StandardServer.java:505)
     at org.apache.catalina.startup.Catalina.start(Catalina.java:776)
     at org.apache.catalina.startup.Catalina.execute(Catalina.java:681)
     at org.apache.catalina.startup.Catalina.process(Catalina.java:179)
     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
     at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:42
)
     at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl
.java:28)
     at java.lang.reflect.Method.invoke(Method.java:313)
     at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:243)

------------------------
    Joel P. Worrall
Senior Software Engineer
     CommNav, Inc.
  (717) 796-1936 x274
  jworrall at commnav.com
jpworrall at programmer.net
 home - (717) 796-2314
 Tango the gifted Llama
-------------------------



--__--__--

Message: 21
Reply-To: <jworrall at commnav.com>
From: "Joel P. Worrall" <jworrall at commnav.com>
To: <jdom-interest at jdom.org>
Subject: RE: [jdom-interest] JDOM Xerces and Xalan versions
Date: Wed, 24 Oct 2001 17:40:16 -0400

Martin:

I copied and compiled your code.  Changed my call to instantiate a new
XercesBuilder().  Now, the next section of errors crops up on the same
classes.  I'm not the brightest bulb on the tree, but this smells like a
ClasLoader issue.  Any help?

Stack trace below.

javax.servlet.ServletException: Servlet.init() for servlet FrontController
threw exception
     at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:871)
     at
org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:
3267)
     at
org.apache.catalina.core.StandardContext.start(StandardContext.java:3384)
.... more
----- Root Cause -----
java.lang.IncompatibleClassChangeError
     at org.jdom.input.SAXBuilder.configureParser(SAXBuilder.java:450)
     at org.jdom.input.SAXBuilder.build(SAXBuilder.java:284)
     at org.jdom.input.SAXBuilder.build(SAXBuilder.java:583)
     at
com.commnav.sbh.framework.config.ServletConfigConfiguration.<init>(ServletCo
nfigConfiguration.java:42)


-----Original Message-----
From: Martin Bravenboer [mailto:mbravenb at students.cs.uu.nl]
Sent: Wednesday, October 24, 2001 4:50 PM
To: jworrall at commnav.com
Cc: jdom-interest at jdom.org
Subject: Re: [jdom-interest] JDOM Xerces and Xalan versions


Hey,


> I am experiencing ClassCastException when attempting to use the JDOM
> SAXBuilder with Tomcat 4.0.1 on the JDK 1.4.  It's trying to cast a
> SAXParser to an XMLReader (which I have built the source for and know it
> implements... very strange)


I had exactly the same problem, with JDK 1.4 beta 2 and Tomcat. I used a
very dirty hack to solve it. I didn't understand the problem (have tried
quite a lot of options) and had to use Xerces for XML Schema support.

import org.jdom.input.SAXBuilder;
import org.apache.xerces.parsers.SAXParser;
import org.xml.sax.XMLReader;

public class XercesBuilder extends SAXBuilder
{
     public XercesBuilder(boolean validating)
     {
          super(validating);
     }

     protected XMLReader createParser() throws Exception
     {
          return new SAXParser();
     }
}

Hope anyone can find out what's going, it's really very obscure.

Greetings,
Martin



--__--__--

_______________________________________________
To control your jdom-interest membership:
http://lists.denveronline.net/mailman/options/jdom-interest/youraddr@yourhost.com

End of jdom-interest Digest






More information about the jdom-interest mailing list