xml-general mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ne...@ca.ibm.com
Subject Re: Crimson questions
Date Fri, 08 Feb 2002 17:48:59 GMT
Hi Simon,

One obvious thing you could try to shrink the size of Xerces2's
xercesImpl.jar is to compress the jarfile.  By default it comes
uncompressed--I'd be curious to know by what percentage compression
decreases its size.

If you must use JAXP though I don't think you'll have much luck excluding
Xerces2 classes.  The reason is that JAXP pulls in Xerces's DOM
implementation which pulls in our serialization code which pulls in our
HTML and WML DOM support...  If you wanted to use XNI though
it would be really interesting to se just how small you could go; my guess
is that you could get yourself a very optimized jarfile if you went down
this road (though I don't think anyone has tried unfortunately).

Hope that helps,
Neil
Neil Graham
XML Parser Development
IBM Toronto Lab
Phone:  905-413-3519, T/L 969-3519
E-mail:  neilg@ca.ibm.com



"Simon McClenahan" <simon.mcclenahan@stellent.com> on 02/08/2002 12:19:18
PM

Please respond to general@xml.apache.org

To:   "xml. apache. org General (E-mail)" <general@xml.apache.org>
cc:
Subject:  Crimson questions


I want to bundle a JAXP compliant XML parser with my application, with
the requirement that the jar file is as small as possible. From what I
can tell, between Crimson, Xerces1 and Xerces2, I am using Crimson
because of its smaller jar size. However, if there is a way to
distribute Xerces2 without all the classes that I don't use so that it
reduces the size of the jar, that would be preferable.

Now that I'm using Crimson, I have a technical question about
serialization, and apparently this list is the only forum for Crimson
discussion.

I can serialize a Document fine, but I haven't figured out how to
serialize any other type of DOM Node. My code is:

----------------------------------------------------------------------
           public static String serializeToString(Node aNode) {
                     String myResult = null;
                     // Crimson implementation
                     StringWriter myStringWriter = new StringWriter();
                     short myNodeType = aNode.getNodeType();
                     try {
                               switch (myNodeType) {
                                          case Node.DOCUMENT_NODE :
                                                     ((XmlDocument)
aNode).write(myStringWriter, XMLUtils.ENCODING_UTF_8);
                                                    break;
                                          default :
                                                    XmlDocument
myXmlDocument =
(XmlDocument) aNode.getOwnerDocument();

myXmlDocument.writeChildrenXml(

myXmlDocument.createWriteContext(myStringWriter, 0));
                                                    break;
                               }
                     } catch (IOException e) {
                               String myMsg = "Unable to serialize DOM
Node: "
+ e.getMessage();
                               throw new RuntimeException(myMsg);
                     }
                     myResult = myStringWriter.toString();
                     return myResult;
           }
----------------------------------------------------------------------

However, the default non-Document case returns an empty String. From
what I can tell this is because Crimson does not see any children of the
given DOM Node and exits early without serializing anything.

Specifically, I would like to serialize an Element. Do I have to write a
hack that creates a new XmlDocument, import the Element, then serialize
the XmlDocument without the XML header information currently hard coded
in XmlDocument.write() ?

cheers,
           Simon

---------------------------------------------------------------------
In case of troubles, e-mail:     webmaster@xml.apache.org
To unsubscribe, e-mail:          general-unsubscribe@xml.apache.org
For additional commands, e-mail: general-help@xml.apache.org





---------------------------------------------------------------------
In case of troubles, e-mail:     webmaster@xml.apache.org
To unsubscribe, e-mail:          general-unsubscribe@xml.apache.org
For additional commands, e-mail: general-help@xml.apache.org


Mime
View raw message