B
Big Bad Munda
Hello,
I am trying to create an XML document using JAXP. I want to associate
it with a *.xsd file. How do I do that? I know if I wanted to
specify a DTD I would do something like this:
DocumentBuilderFactory factory =
DocumentBuilderFactory.newInstance();
factory.setValidating(true);
DocumentBuilder builder = factory.newDocumentBuilder();
// Create DTD definition
DOMImplementation domImpl = builder.getDOMImplementation();
DocumentType docType = domImpl.createDocumentType("DeviceQuery",
null, "dtd/ToolsDeviceQueryInfo.dtd");
Document toolsDoc = domImpl.createDocument(null, "DeviceQuery",
docType);
But what is the corresponding code to associate it with an .xsd file.
I have been unable to find any documentation on this.
The following is what I want the end result to look like:
<?xml version="1.0" encoding="UTF-8" ?>
<DeviceQuery
xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
xsi:noNamespaceSchemaLocation="DomainDeviceQueryResult.xsd">
<RequesterInfo>
<DQKey>12345</DQKey>
<Server>localhost:7001</Server>
</RequesterInfo>
</DeviceQuery>
Any help would be much appreciated!
Ashish
I am trying to create an XML document using JAXP. I want to associate
it with a *.xsd file. How do I do that? I know if I wanted to
specify a DTD I would do something like this:
DocumentBuilderFactory factory =
DocumentBuilderFactory.newInstance();
factory.setValidating(true);
DocumentBuilder builder = factory.newDocumentBuilder();
// Create DTD definition
DOMImplementation domImpl = builder.getDOMImplementation();
DocumentType docType = domImpl.createDocumentType("DeviceQuery",
null, "dtd/ToolsDeviceQueryInfo.dtd");
Document toolsDoc = domImpl.createDocument(null, "DeviceQuery",
docType);
But what is the corresponding code to associate it with an .xsd file.
I have been unable to find any documentation on this.
The following is what I want the end result to look like:
<?xml version="1.0" encoding="UTF-8" ?>
<DeviceQuery
xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
xsi:noNamespaceSchemaLocation="DomainDeviceQueryResult.xsd">
<RequesterInfo>
<DQKey>12345</DQKey>
<Server>localhost:7001</Server>
</RequesterInfo>
</DeviceQuery>
Any help would be much appreciated!
Ashish