Cannot get XInclude to work. Searched archives for XInclude, and while there are quite a few entries, and even some claim of success, none provide the steps required to get there.

I would appreciate it if anyone can help me out with this, and/or provide samples.

Following is the test I setup:

Configuration:
 Windows XP
 Cygwin
 JDK1.4.2-b28
 Xerces 2.6.0

Xerces jar files in:
 $JAVA_HOME/lib/endorsed
 $JAVA_HOME/jre/lib/endorsed
(was not sure where to put them so put them in both).


Compile and Run commands: XD=org.apache.xerces.xni.parser.XMLParserConfiguration XI=org.apache.xerces.parsers.XIncludeParserConfiguration

  javac -classpath . Test.java
  java -classpath . -D"$XD=$XI" Test


----- Test Class ---------------- import org.apache.xerces.parsers.DOMParser; import org.apache.xml.serialize.XMLSerializer; import org.apache.xml.serialize.OutputFormat; import org.w3c.dom.Document; import java.io.StringWriter;

public class Test {
 public static void main (String [] args) {
  try {
    DOMParser p = new DOMParser();
    p.parse("contact.xml");

    Document d = p.getDocument();

    StringWriter out = new StringWriter();
    (new XMLSerializer(out, new OutputFormat())).serialize(d);

    System.err.println(out.toString());
  }
  catch (Exception e) {
    e.printStackTrace();
  }
 }
}

----- contact.xml -----
<?xml version="1.0" encoding="UTF-8"?>
<contact xmlns:xi="http://www.w3.org/2003/XInclude";>
  <xi:include href="name.xml"/>
  <!-- <xi:include href="file:name.xml"/> -->
  <!-- <xi:include href="file:/name.xml"/> -->
  <!-- <xi:include href="file:///name.xml"/> -->
  <!-- <xi:include href="file:///home/angus/.../name.xml"/> -->
  <!-- <xi:include href="file:///C:/.../name.xml"/> -->
</contact>

----- name.xml -----
<?xml version="1.0" encoding="UTF-8"?>
<name>
  <first/>
  <last/>
  <initial/>
  <title/>
</name>




--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to