lenya/src/java/org/apache/lenya/xml DocumentHelper.java,1.12,1.13

Christian Egli <[email protected]>
Newsgroups gmane.comp.cms.wyona.cvs
Message-ID <[email protected]>
Update of /repository/lenya/src/java/org/apache/lenya/xml
In directory erbium:/tmp/cvs-serv2065/src/java/org/apache/lenya/xml

Modified Files:
	DocumentHelper.java 
Log Message:
Added doctype handling to the writer methods. The doctype is queried
from the document and consequently the transformer (which is needed
for writing) is configured with the doctype.


Index: DocumentHelper.java
===================================================================
RCS file: /repository/lenya/src/java/org/apache/lenya/xml/DocumentHelper.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -C2 -d -r1.12 -r1.13
*** DocumentHelper.java	24 Apr 2003 13:53:14 -0000	1.12
--- DocumentHelper.java	8 May 2003 15:38:02 -0000	1.13
***************
*** 166,170 ****
          DOMSource source = new DOMSource(document);
          StreamResult result = new StreamResult(file);
!         getTransformer().transform(source, result);
      }
      
--- 166,170 ----
          DOMSource source = new DOMSource(document);
          StreamResult result = new StreamResult(file);
!         getTransformer(document.getDoctype()).transform(source, result);
      }
      
***************
*** 182,193 ****
          DOMSource source = new DOMSource(document);
          StreamResult result = new StreamResult(writer);
!         getTransformer().transform(source, result);
      }
      
!     protected static Transformer getTransformer()
              throws TransformerConfigurationException {
          TransformerFactory factory = TransformerFactory.newInstance();
          Transformer transformer = factory.newTransformer();
          transformer.setOutputProperty(OutputKeys.INDENT, "yes");
          return transformer;
      }
--- 182,196 ----
          DOMSource source = new DOMSource(document);
          StreamResult result = new StreamResult(writer);
!         getTransformer(document.getDoctype()).transform(source, result);
      }
      
!     protected static Transformer getTransformer(DocumentType documentType)
              throws TransformerConfigurationException {
          TransformerFactory factory = TransformerFactory.newInstance();
          Transformer transformer = factory.newTransformer();
          transformer.setOutputProperty(OutputKeys.INDENT, "yes");
+ 	if (documentType != null) {
+ 	    transformer.setOutputProperty(OutputKeys.DOCTYPE_PUBLIC, documentType.getPublicId());
+ 	}
          return transformer;
      }
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.