Example usage for javax.xml.transform.dom DOMResult getSystemId

List of usage examples for javax.xml.transform.dom DOMResult getSystemId

Introduction

In this page you can find the example usage for javax.xml.transform.dom DOMResult getSystemId.

Prototype

public String getSystemId() 

Source Link

Document

Get the System Identifier.

Usage

From source file:org.javelin.sws.ext.bind.jaxb.JaxbTest.java

@Test
public void generateXmlSchema() throws Exception {
    JAXBContext ctx = JAXBContext.newInstance(org.javelin.sws.ext.bind.jaxb.context2.MyClassJ2.class,
            org.javelin.sws.ext.bind.jaxb.context3a.MyClassJ3.class);

    final List<DOMResult> results = new LinkedList<DOMResult>();

    ctx.generateSchema(new SchemaOutputResolver() {
        @Override/* w w w. j  a  va 2  s .  c o  m*/
        public Result createOutput(String namespaceUri, String suggestedFileName) throws IOException {
            log.info("file: {}, namespace: {}", suggestedFileName, namespaceUri);
            DOMResult result = new DOMResult();
            results.add(result);
            result.setSystemId(suggestedFileName);
            return result;
        }
    });

    for (DOMResult dr : results) {
        log.info("=== {} ===", dr.getSystemId());
        javax.xml.transform.TransformerFactory.newInstance().newTransformer().transform(
                new javax.xml.transform.dom.DOMSource(dr.getNode()),
                new javax.xml.transform.stream.StreamResult(new java.io.PrintWriter(System.out)));
    }
}

From source file:pl.nask.hsn2.workflow.parser.HWLParser.java

private void createSchema() throws IOException, SAXException {
    final DOMResult result = new DOMResult();

    SchemaOutputResolver outputResolver = new HwlSchemaOutputResolver(result);

    ctx.generateSchema(outputResolver);/* w  ww .  j  a v  a 2 s.  com*/
    this.schemaNode = result.getNode();
    this.schemaSystemId = result.getSystemId();

    Source source = new DOMSource(schemaNode, schemaSystemId);

    this.schema = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI).newSchema(source);
}