public virtual void testAppendElement() { JDFDoc d = new JDFDoc("JDF"); KElement r = d.getRoot(); KElement e = r.appendElement("e"); Assert.AreEqual(e.getNamespaceURI(), JDFElement.getSchemaURL()); KElement foo = e.appendElement("pt:foo", "www.pt.com"); Assert.AreEqual("www.pt.com", foo.getNamespaceURI()); KElement bar = foo.appendElement("bar"); Assert.IsNotNull(bar.getNamespaceURI()); KElement foo2 = bar.appendElement("pt:foo", "www.pt.com"); Assert.AreEqual("www.pt.com", foo2.getNamespaceURI()); }
/// /// * <param name="schemaLocation"> </param> /// * <param name="documentClassName"> </param> /// * <param name="ErrorHandler"> default: initParser(null, DocumentJDFImpl.class.getName(), null); </param> /// private void initParser(string schemaLocation, string documentClassName) { m_SchemaLocation = schemaLocation; m_DocumentClass = documentClassName; try { if (m_SchemaLocation == null || m_SchemaLocation.Equals(JDFConstants.EMPTYSTRING)) { this.setFeature("http://xml.org/sax/features/validation", false); this.setFeature("http://apache.org/xml/features/validation/schema", false); } else { if (!m_SchemaLocation.StartsWith(JDFElement.getSchemaURL())) { m_SchemaLocation = JDFElement.getSchemaURL() + " " + m_SchemaLocation; } this.setFeature("http://xml.org/sax/features/validation", true); this.setFeature("http://apache.org/xml/features/validation/schema", true); // this.setFeature( // "http://apache.org/xml/features/validation/schema/element-default" // , false); // this.setFeature( // "http://apache.org/xml/features/validation/schema/normalized-value" // , false); this.setProperty("http://apache.org/xml/properties/schema/external-schemaLocation", m_SchemaLocation); } // use our own JDF document for creating JDF elements this.setProperty("http://apache.org/xml/properties/dom/document-class-name", documentClassName); this.setFeature("http://apache.org/xml/features/dom/defer-node-expansion", false); this.setFeature("http://xml.org/sax/features/namespaces", true); } catch (Exception e) { m_lastExcept = e; } }