forked from patniemeyer/learningjava
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPrintXInclude.java
More file actions
23 lines (22 loc) · 810 Bytes
/
Copy pathPrintXInclude.java
File metadata and controls
23 lines (22 loc) · 810 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import javax.xml.parsers.*;
import org.w3c.dom.*;
import javax.xml.transform.*;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
public class PrintXInclude {
public static void main( String [] args ) throws Exception
{
DocumentBuilderFactory factory =
DocumentBuilderFactory.newInstance();
factory.setNamespaceAware( true );
factory.setXIncludeAware( true );
DocumentBuilder parser = factory.newDocumentBuilder();
System.out.println( "aware: "+parser.isXIncludeAware() );
Document document = parser.parse( "chapter.xml" );
Transformer transformer =
TransformerFactory.newInstance().newTransformer();
Source source = new DOMSource( document );
Result output = new StreamResult( System.out );
transformer.transform( source, output );
}
}