Hello, Well, as suggested weeks ago, you'll find below the necessary -and small- patches that will prevent Jboss from being linked to xml.jar. Indeed the JAXP spec from sun brings Factories on top of SAX parser and DOM builder, so I believe Jboss should make use of these simple APIs so that you just drag and drop a JAXP compliant parser in the lib/ext and jboss automatically uses it. You'll find the diff for org.jboss.configuration.ConfigurationService.java and org.jboss.configuration.metadata.XmlFileLoader.java and there is a DOMSerializer that serialize a DOM document to a writer. The DOMSerializer is used in the XMLfileLoader.java. It's a simple serializer that fills the need for jboss. If you plan to get a more sophisticated serializer there are some available from public domain : SaxWriter from meggison (SAX's father) and TRAX, but both of them use SAX2 interfaces so you'll then need a SAX1 adapter. That's why I thought a simple DOMserializer will be enough for now. What do you think ? You'll then need to replace xml.jar with jaxp.jar and parser.jar available from http://www.javasoft.com/xml or the xerces parser which implements the JAXP parser http://xml.apache.org If other tools from jboss (i'm thinking of EJX) does use xml.jar directly (importing the com.sun.xml.* packages), then switching to parser.jar will be painless since it's the same classes as xml.jar with some small bug fixes. If you have any question please don't hesitate. All the best, Sebastien ---------------------------------- ---------------------------------- DIFF: ---------------------------------- Index: ./src/main/org/jboss/configuration/ConfigurationService.java =================================================================== RCS file: /products/cvs/ejboss/jboss/src/main/org/jboss/configuration/Configuratio nService.java,v retrieving revision 1.3 diff -r1.3 ConfigurationService.java 20c20,21 < import com.sun.xml.tree.*; --- > import javax.xml.parsers.DocumentBuilderFactory; > import javax.xml.parsers.DocumentBuilder; 79,82c80,81 < XmlDocumentBuilder xdb = new XmlDocumentBuilder(); < Parser parser = new com.sun.xml.parser.Parser(); < xdb.setParser(parser); < --- > DocumentBuilder xdb = DocumentBuilderFactory.newInstance().newDocumentBuilder(); > 85,86c84 < parser.parse(new InputSource(new StringReader(configuration))); < doc = xdb.getDocument(); --- > doc = xdb.parse(new InputSource(new StringReader(configuration))); 152,154c150,153 < // Create new ProjectX XML doc < XmlDocument doc = new XmlDocument(); < --- > // Create new doc from JAXP factory > DocumentBuilder db = DocumentBuilderFactory.newInstance().newDocumentBuilder(); > Document doc = db.newDocument(); > 191,192c190,192 < // Write configuration < doc.writeXml(new XmlWriteContext(out,3)); --- > org.jboss.util.DOMSerializer ser = new org.jboss.util.DOMSerializer(doc, out); > ser.process(); > Index: ./src/main/org/jboss/metadata/XmlFileLoader.java =================================================================== RCS file: /products/cvs/ejboss/jboss/src/main/org/jboss/metadata/XmlFileLoader.jav a,v retrieving revision 1.4 diff -r1.4 XmlFileLoader.java 15a16,18 > import javax.xml.parsers.DocumentBuilder; > import javax.xml.parsers.DocumentBuilderFactory; > 19d21 < import org.xml.sax.Parser; 124a127,128 > > DocumentBuilder db = DocumentBuilderFactory.newInstance().newDocumentBuilder(); 126,128d129 < com.sun.xml.tree.XmlDocumentBuilder xdb = new com.sun.xml.tree.XmlDocumentBuilder(); < < Parser parser = new com.sun.xml.parser.Parser(); 132,133c133 < parser.setEntityResolver(er); < xdb.setParser(parser); --- > db.setEntityResolver(er); 135,136c135 < parser.parse(new InputSource(in)); < return xdb.getDocument(); --- > return db.parse(new InputSource(in)); ---------------------------- ---------------------------- DOMSerializer.java : ---------------------------- package org.jboss.util; import java.util.Vector; import org.w3c.dom.Attr; import org.w3c.dom.CDATASection; import org.w3c.dom.Comment; import org.w3c.dom.Document; import org.w3c.dom.DocumentType; import org.w3c.dom.Element; import org.w3c.dom.EntityReference; import org.w3c.dom.NamedNodeMap; import org.w3c.dom.Node; import org.w3c.dom.NodeList; import org.w3c.dom.ProcessingInstruction; import org.w3c.dom.Text; import java.io.Writer; import java.io.IOException; /** * The <code>DOMSerializer</code> is a utility class that will serialize * a W3C DOM Document into a writer. * * @author <a href="mailto:[EMAIL PROTECTED]">Sebastien Sahuc</a> */ public class DOMSerializer { static String eol; int indent = 0; /** The <code>Writer</code>. */ protected Writer out=null; /** The DOM <code>Node</code>. */ protected Node node = null; /** * Create a new <code>DOMSerializer</code> instance from a DOM object and a Writer. */ public DOMSerializer(Node node, Writer writer) { this.node = node; this.out = writer; eol = System.getProperty ("line.separator", "\n"); } /** * Start the serialization. */ public void process () throws IOException { try { processNode((Node)node); } catch (ClassCastException e) { throw new IOException (e.toString()); } } /** Process a generic node */ private void processNode(Node n) throws IOException { if (n==null) return; try { switch (n.getNodeType()) { case Node.DOCUMENT_NODE: this.setDocument((Document)n); break; case Node.DOCUMENT_TYPE_NODE: this.setDocumentType((DocumentType)n); break; case Node.ELEMENT_NODE: this.setElement((Element)n); break; case Node.TEXT_NODE: this.setText((Text)n); break; case Node.CDATA_SECTION_NODE: this.setCDATASection((CDATASection)n); break; case Node.PROCESSING_INSTRUCTION_NODE: this.setProcessingInstruction((ProcessingInstruction)n); break; case Node.COMMENT_NODE: this.setComment((Comment)n); break; case Node.ENTITY_REFERENCE_NODE: this.setEntityReference((EntityReference)n); break; case Node.ENTITY_NODE: case Node.NOTATION_NODE: // Do nothing for ENTITY and NOTATION nodes break; case Node.DOCUMENT_FRAGMENT_NODE: throw new IOException ("Unexpected Document Fragment node"); case Node.ATTRIBUTE_NODE: throw new IOException ("Unexpected Attribute node"); default: throw new IOException ("Unknown node type "+n.getNodeType()+ " class "+n.getClass().getName()); } } catch (ClassCastException e) { throw new IOException ("Error casting node to appropriate type"); } } /** Process all children nodes of a Node */ private void processChildren(Node n) throws IOException { NodeList l=n.getChildNodes(); for(int x=0;x<l.getLength();x++) processNode(l.item(x)); } /** Process a Document node */ private void setDocument(Document n) throws IOException { out.write ("<?xml version=\"1.0\""); out.write ("?>"); out.write (eol); out.write (eol); this.processChildren(n); out.write (eol); out.flush (); } /** Process a DocumentType node */ private void setDocumentType(DocumentType n) { return; } /** Process a Element node */ private void setElement(Element n) throws IOException { indent += 2; printIdent(); out.write ("<", 0, 1); out.write (n.getTagName()); NamedNodeMap map=n.getAttributes(); if (map != null) { Vector nslist=new Vector(); for (int x=0; x<map.getLength(); x++) { if (map.item(x).getNodeType()!=Node.ATTRIBUTE_NODE) continue; Attr a=(Attr)map.item(x); setAttribute(a); } } if (!n.hasChildNodes ()) out.write (" />"); else { out.write (">"); this.processChildren(n); out.write ("</"); out.write (n.getTagName()); out.write (">"); } indent -= 2; printIdent(); } private void setText(Text n) throws IOException { char[] data=n.getData().toCharArray(); int start = 0, last = 0; while (last < data.length) { char c = data [last]; if (c == '<') { out.write (data, start, last - start); start = last + 1; out.write ("<"); } else if (c == '>') { out.write (data, start, last - start); start = last + 1; out.write (">"); } else if (c == '&') { out.write (data, start, last - start); start = last + 1; out.write ("&"); } last++; } out.write (data, start, last - start); } /** Process a Text node */ private void setAttribute(Attr attr) throws IOException { out.write (" "); out.write (attr.getName()); out.write ("=\""); String value = attr.getValue(); for (int i = 0; i < value.length (); i++) { int c = value.charAt (i); switch (c) { case '<': out.write ("<"); continue; case '>': out.write (">"); continue; case '&': out.write ("&"); continue; case '\'': out.write ("'"); continue; case '"': out.write ("""); continue; default: out.write (c); continue; } } out.write ('"'); } /** Process a CDATASection node */ private void setCDATASection(CDATASection n) { char data[]=n.getData().toCharArray(); //out.write(data); return; } /** Process a ProcessingInstruction node */ private void setProcessingInstruction(ProcessingInstruction n) { return; } /** Process a Comment node */ private void setComment(Comment n) { return; } /** Process a EntityReference node */ private void setEntityReference(EntityReference n) { return; } private void printIdent() throws IOException { int temp = indent; out.write (eol); while (temp-- > 0) out.write (' '); } }
