Hello, I have written a small java program which does an XInclude via the xerces parser which is part of Java 6.0 ( com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl).
The output includes the following signs at each line end: Is there a way to prevent this; this is creating additional lines into my output? Detailled example below. Best regards, Lars ***************************************************************/ package test; import java.io.File; import java.io.FileOutputStream; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.transform.OutputKeys; import javax.xml.transform.Transformer; import javax.xml.transform.TransformerFactory; import javax.xml.transform.dom.DOMSource; import javax.xml.transform.stream.StreamResult; import org.w3c.dom.Document; public class MyXIncluder { public void extractXMLFile(String in, String out) throws Exception { Document document = null; File file; com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpltest; file = new File(in); file.getAbsolutePath(); file.lastModified(); DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); System.out.println(dbf.getClass().toString()); dbf.setXIncludeAware(true); dbf.setNamespaceAware(true); DocumentBuilder dom = dbf.newDocumentBuilder(); document = dom.parse(file); // ---- Use a XSLT transformer for writing the new XML file ---- Transformer transformer = TransformerFactory.newInstance() .newTransformer(); // TODO: This should be read from the input file and not hardcoded // here transformer.setOutputProperty(OutputKeys.DOCTYPE_PUBLIC, "-//OASIS//DTD DocBook XML V4.5//EN"); transformer.setOutputProperty(OutputKeys.DOCTYPE_SYSTEM, "../../docbook-xml-4.5/docbookx.dtd"); DOMSource source = new DOMSource(document); FileOutputStream os = new FileOutputStream(new File(out)); StreamResult result = new StreamResult(os); transformer.transform(source, result); } public static void main(String[] args) { MyXIncluder test = new MyXIncluder(); try { test.extractXMLFile("article.xml", "articleout.xml"); } catch (Exception e) { e.printStackTrace(); System.out.println(e.getMessage()); } System.out.println("Done"); } } ------------ Example article.xml: <?xml version="1.0"?> <article> <articleinfo> <title> Blabla </title> <abstract id="abstract"> <title>Abstract</title> <para> Blablabla </para> </abstract> </articleinfo> <para> <programlisting> <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" parse="text" href="JavaScript.java" /> </programlisting> </para> </article> And the include file: -------- package counter; import java.io.IOException; import java.io.PrintWriter; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; import database.Database; /** * Servlet implementation class for Servlet: DatabaseCounter * */ public class JavaScript extends javax.servlet.http.HttpServlet implements javax.servlet.Servlet { static final long serialVersionUID = 1L; int count; private Database db; /* * (non-Java-doc) * * @see javax.servlet.http.HttpServlet#HttpServlet() */ public JavaScript() { super(); } } -------------------