Note that there are some explanatory texts on larger screens.

plurals
  1. PODynamically generating XML Schema
    primarykey
    data
    text
    <p>I am trying to dynamically generate XML schema using Xerces-J and getting the following error, appreciate any help regarding it.</p> <pre><code>DocumentBuilderFactory dbfac = DocumentBuilderFactory.newInstance(); dbfac.setNamespaceAware(true); DocumentBuilder docBuilder = dbfac.newDocumentBuilder(); Document doc = docBuilder.newDocument(); Element schema = doc.createElement("xs:schema"); schema.setAttribute("xmlns:xs", "http://www.w3.org/2001/XMLSchema"); doc.appendChild(schema); Element e = doc.createElement("xs:element"); e.setAttribute("name", "test"); e.setAttribute("type", "xs:string"); schema.appendChild(e); TransformerFactory transfac = TransformerFactory.newInstance(); Transformer trans = transfac.newTransformer(); trans.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "no"); trans.setOutputProperty(OutputKeys.INDENT, "yes"); //create string from xml tree StringWriter sw = new StringWriter(); StreamResult result = new StreamResult(sw); DOMSource source = new DOMSource(doc); trans.transform(source, result); String xmlString = sw.toString(); System.out.println(xmlString); SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI); Schema schema1 = schemaFactory.newSchema(source); Output is &lt;?xml version="1.0" encoding="UTF-8" standalone="no"?&gt; &lt;xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"&gt; &lt;xs:element name="test" type="xs:string"/&gt; &lt;/xs:schema&gt; </code></pre> <p>org.xml.sax.SAXParseException: s4s-elt-schema-ns: The namespace of element 'xs:schema' must be from the schema namespace, 'http://www.w3.org/2001/XMLSchema'.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload