Validation of XML document % DTD

I need method which allows to check if an XML document is valid regards its DTD. is it possible?
I use JDOM.
thanks,

I need method which allows to check if an XML
document is valid regards its DTD. is it possible?
I use JDOM.But it would be the parser that validates the XML against its DTD. JDOM is not a parser, it uses some other product (which you can specify, I believe) to do the parsing. So the answer would be yes, since parsers do exist that can validate against a DTD.

Similar Messages

  • Validating a xml document via dtd or xml schema

    hi.
    i am trying to validate a xml document's structure via dtd or xml schema. unfortunately i dont have a clue how to do this. although i read some documents about it i didnt find a way to it yet.
    i am using dom4j to build a org.dom4j.Document from a String.
    my expectations were like this:
    - read data into string
    - create org.dom4j.Document from a string
    - after successfully creating the document calling document.validate(xmlSchema) throwing a ParseException (or something like this when the xml doesnt meet the requirements given by the schema)
    please help!

    Class org.dom4j.Document does not have a validate() method.

  • Validating an xml with DTD external DTD

    Hi
    how can i validate my XML File with an external DTD ?
    thanks for your replies
    serge

    Hi,
    when you use the XML Library, the interface <b>if_ixml_parser</b> has a static method <b>set_validation( )</b> to activate and deactivate a DTD validation.
    There are the follow constants in the if_ixml_parser for the DTD validation-mode:
    <b>if_ixml_parser=>co_no_validation</b>
    Do not validate the XML-Document against the document type definition (DTD)
    <b>if_ixml_parser=>co_validate</b>
    Validate the XML-Document against the document type definition (DTD)
    <b>if_ixml_parser=>co_validate_if_dtd</b>
    Validate the XML-Document against the document type definition (DTD) if a DTD is specified. Otherwise parse the Document in non validating mode.
    see also the SAP online-help:
    <a href="http://help.sap.com/saphelp_webas610/helpdata/de/bb/5766b2dca511d4990b00508b6b8b11/content.htm">Interface if_ixml_parser</a>
    Regards
    Stefan

  • Validating an XML document to a schema using ColdFusion

    This is something I have never tried before.  We created an XML Schema  to define XML documents we expect to receive from various entities.   When we receive the document, we would like to validate it before  processing it.  I think ColdFusion is up to this from reading the  documentation, but we have not got anything working yet.
    When we try and xmlParse() our test XML file against the XML schema we  get the following error.  When we use a web based XML validation tool  and feed it the same XML file and schema it validates just fine.
    An error occured while parsing an XML document.
    [Error] :2:6: cvc-elt.1: Cannot find the declaration of element 'pur'.
    The error occurred in D:\playground\warren\ppur_file_import.cfm: line 57
    55 :
    56 :
    57 : <cfset xmldoc = XmlParse(ExpandPath(filepath), true,  ExpandPath(validator)) />
    58 : <cfdump var="#xmldoc#">
    59 : <cfabort>
    Searching for the error has not provided me any useful hints.  Can  anybody here?

    XML SCHEMA
    <?xml version="1.0" encoding="iso-8859-1"?>
    <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
         <!-- Simple Types -->
         <xs:simpleType name="RECORD_ID">
              <xs:restriction base="xs:string">
                   <xs:pattern value="[AaBbCc]"/>
              </xs:restriction>
         </xs:simpleType>
         <xs:simpleType name="REPORT_MONTH">
              <xs:restriction base="xs:integer">
                   <xs:pattern value="(0[1-9]|1[0-2])"/>
              </xs:restriction>
         </xs:simpleType>
         <xs:simpleType name="REPORT_YEAR">
              <xs:restriction base="xs:integer">
                   <xs:pattern value="[0-9]{2}"/>
              </xs:restriction>
         </xs:simpleType>
         <xs:simpleType name="MFG_FIRMNO">
              <xs:restriction base="xs:integer">
                   <xs:pattern value="[0-9]{7}"/>
              </xs:restriction>
         </xs:simpleType>
         <xs:simpleType name="LABEL_SEQ_NO">
              <xs:restriction base="xs:integer">
                   <xs:pattern value="[0-9]{5}"/>
              </xs:restriction>
         </xs:simpleType>     
         <xs:simpleType name="REVISION_NO">
              <xs:restriction base="xs:string">
                   <xs:pattern value="[A-Za-z]{2}"/>
              </xs:restriction>
         </xs:simpleType>
         <xs:simpleType name="REG_FIRMNO">
              <xs:restriction base="xs:integer">
                   <xs:pattern value="[0-9]{7}"/>
              </xs:restriction>
         </xs:simpleType>
         <xs:simpleType name="GROWER_ID">
              <xs:restriction base="xs:integer">
                   <xs:pattern value="[0-9]{11}"/>
              </xs:restriction>
         </xs:simpleType>
         <xs:simpleType name="CEDTS_IND">
              <xs:restriction base="xs:string">
                   <xs:pattern value="[Ee]|[ ]"/>
                   <!-- needs to match E or a blank. -->
              </xs:restriction>
         </xs:simpleType>
         <xs:simpleType name="APPLIC_DT">
              <xs:restriction base="xs:integer">
                   <xs:pattern value="(0[1-9]|1[0-2])(0[1-9]|[1-2][0-9]|3[0-1])([0-9]{2})"/>
              </xs:restriction>
         </xs:simpleType>
         <xs:simpleType name="SITE_CODE">
              <xs:restriction base="xs:integer">
                   <xs:pattern value="[0-9]{6}"/>
              </xs:restriction>
         </xs:simpleType>
         <xs:simpleType name="QUALIFY_CD">
              <xs:restriction base="xs:integer">
                   <xs:pattern value="[0-9]{2}"/>
              </xs:restriction>
         </xs:simpleType>     
         <xs:simpleType name="PLANTING_SEQ">
              <xs:restriction base="xs:integer">
                   <xs:pattern value="[0-9]"/>
              </xs:restriction>
         </xs:simpleType>
         <xs:simpleType name="ACRE_TREATED">
              <xs:restriction base="xs:integer">
                   <xs:pattern value="[0-9]{8}"/>
              </xs:restriction>
         </xs:simpleType>
         <xs:simpleType name="UNIT_TREATED">
              <xs:restriction base="xs:string">
                   <xs:pattern value="[ATSCKUPatsckup]"/>
              </xs:restriction>
         </xs:simpleType>
         <xs:simpleType name="AMT_PRD_USED">
              <xs:restriction base="xs:integer">
                   <xs:pattern value="[0-9]{10}"/>
              </xs:restriction>
         </xs:simpleType>
         <xs:simpleType name="UNIT_OF_MEAS">
              <xs:restriction base="xs:string">
                   <xs:pattern value="LB|OZ|GA|QT|PT|KG|GR|LI|ML"/>
              </xs:restriction>
         </xs:simpleType>
         <xs:simpleType name="DOCUMENT_NO">
              <xs:restriction base="xs:integer">
                   <xs:pattern value="[0-9]{8}"/>
              </xs:restriction>
         </xs:simpleType>
         <xs:simpleType name="LINE_ITEM">
              <xs:restriction base="xs:integer">
                   <xs:pattern value="[0-9]{4}"/>
              </xs:restriction>
         </xs:simpleType>
         <xs:simpleType name="PROCESS_DT">
              <xs:restriction base="xs:integer">
                   <xs:pattern value="[0-9]{4}"/>
              </xs:restriction>
         </xs:simpleType>
         <xs:simpleType name="BATCH_NO">
              <xs:restriction base="xs:integer">
                   <xs:pattern value="[0-5][0-9][0-9][0-9]"/>
              </xs:restriction>
         </xs:simpleType>
         <xs:simpleType name="COUNTY_CD">
              <xs:restriction base="xs:integer">
                   <xs:pattern value="[0-5][0-9]"/>
              </xs:restriction>
         </xs:simpleType>
         <xs:simpleType name="SECTION">
              <xs:restriction base="xs:integer">
                   <xs:pattern value="[0-9]{2}"/>
              </xs:restriction>
         </xs:simpleType>
         <xs:simpleType name="TOWNSHIP">
              <xs:restriction base="xs:integer">
                   <xs:pattern value="[0-9]{2}"/>
              </xs:restriction>
         </xs:simpleType>
         <xs:simpleType name="TSHIP_DIR">
              <xs:restriction base="xs:string">
                   <xs:pattern value="[NSns]"/>
              </xs:restriction>
         </xs:simpleType>
         <xs:simpleType name="RANGE">
              <xs:restriction base="xs:integer">
                   <xs:pattern value="[0-9]{2}"/>
              </xs:restriction>
         </xs:simpleType>
         <xs:simpleType name="RANGE_DIR">
              <xs:restriction base="xs:string">
                   <xs:pattern value="[EWew]"/>
              </xs:restriction>
         </xs:simpleType>
         <xs:simpleType name="BASE_LN_MER">
              <xs:restriction base="xs:string">
                   <xs:pattern value="[HMShms]"/>
              </xs:restriction>
         </xs:simpleType>
         <xs:simpleType name="AER_GND_IND">
              <xs:restriction base="xs:string">
                   <xs:pattern value="[AFGOafgo]"/>
              </xs:restriction>
         </xs:simpleType>
         <xs:simpleType name="SITE_LOC_ID">
              <xs:restriction base="xs:string">
                   <xs:pattern value="[-0-9 ]+"/>
                   <!-- Examples in files I checked
                         only had numeric characters and
                         a dash. The county contract doesn't
                         specify numeric-only, so letters may
                         be acceptable. I find no evidence of
                         any letters being used. -->
              </xs:restriction>
         </xs:simpleType>
         <xs:simpleType name="ACRE_PLANTED">
              <xs:restriction base="xs:integer">
                   <xs:pattern value="[0-9]{8}"/>
              </xs:restriction>
         </xs:simpleType>
         <xs:simpleType name="UNIT_PLANTED">
              <xs:restriction base="xs:string">
                   <xs:pattern value="[ATSCKUPatsckup]"/>
              </xs:restriction>
         </xs:simpleType>
         <xs:simpleType name="APPLIC_TM">
              <xs:restriction base="xs:integer">
                   <xs:pattern value="[0-9]{4}"/>
              </xs:restriction>
         </xs:simpleType>
         <xs:simpleType name="APPLIC_CNT">
              <xs:restriction base="xs:integer">
                   <xs:pattern value="[0-9]{6}"/>
              </xs:restriction>
         </xs:simpleType>
         <xs:simpleType name="FUME_CD">
              <xs:restriction base="xs:integer">
                   <xs:pattern value="[0-9]{4}"/>
              </xs:restriction>
         </xs:simpleType>
         <xs:simpleType name="LICENSE_NO">
              <xs:restriction base="xs:integer">
                   <xs:pattern value="[-0-9A-Za-z]{13}"/>
              </xs:restriction>
         </xs:simpleType>
         <!-- end Simple Types -->
         <!-- !!!!!!!!! Begin Abstract Types !!!!!!!!! -->
         <xs:complexType name="application_data_abs" abstract="true">
              <xs:sequence>          
                   <xs:element name="GROWER_ID" type="GROWER_ID" />                    
                   <xs:element name="CEDTS_IND" type="CEDTS_IND" />
                   <xs:element name="APPLIC_DT" type="APPLIC_DT" />     
                   <xs:element name="SITE_CODE" type="SITE_CODE" />               
                   <xs:element name="QUALIFY_CD" type="QUALIFY_CD" />
                   <xs:element name="PLANTING_SEQ" type="PLANTING_SEQ" />
                   <xs:element name="ACRE_TREATED" type="ACRE_TREATED" />                         
                   <xs:element name="UNIT_TREATED" type="UNIT_TREATED" />
                   <xs:element name="AMT_PRD_USED" type="AMT_PRD_USED" />
                   <xs:element name="UNIT_OF_MEAS" type="UNIT_OF_MEAS" />               
                   <xs:element name="DOCUMENT_NO" type="DOCUMENT_NO" />                         
                   <xs:element name="LINE_ITEM" type="LINE_ITEM" />
              </xs:sequence>
         </xs:complexType>
         <xs:complexType name="application_abs" abstract="true">
              <xs:sequence>
                   <xs:element name="key_data" type="key_data" />
                   <xs:element name="product_data" type="product_data" />
              </xs:sequence>
         </xs:complexType>
         <!-- !!!!!!!!! End Abstract Types !!!!!!!!! -->
         <!-- !!!!!!!!! Start Complex Types !!!!!!!!! -->
         <xs:complexType name="product_data">
              <xs:sequence>
                   <xs:element name="MFG_FIRMNO" type="MFG_FIRMNO" />               
                   <xs:element name="LABEL_SEQ_NO" type="LABEL_SEQ_NO"/>                         
                   <xs:element name="REVISION_NO" type="REVISION_NO" />
                   <xs:element name="REG_FIRMNO" type="REG_FIRMNO" />               
              </xs:sequence>
         </xs:complexType>
         <xs:complexType name="key_data">
              <xs:sequence>
                   <xs:element name="RECORD_ID" type="RECORD_ID" />     
                   <xs:element name="COUNTY_KEY">
                        <!--
                             The optional COUNTY_ID field would be used by
                             the Counties to include their internal
                             record identifier. This would allow DPR
                             to reference a county's internal record ID
                             in the event of data inconsistencies.
                        -->
                   </xs:element>
                   <xs:element name="REPORT_MONTH" type="REPORT_MONTH" />
                   <xs:element name="REPORT_YEAR" type="REPORT_YEAR" />
              </xs:sequence>
         </xs:complexType>
         <xs:complexType name="fileInfo">
              <xs:sequence>
                   <xs:element name="PROCESS_DT" type="PROCESS_DT" />                              
                   <xs:element name="BATCH_NO" type="BATCH_NO" />
                   <xs:element name="COUNTY_CD" type="COUNTY_CD" />
              </xs:sequence>
         </xs:complexType>     
         <xs:complexType name="mtrs_data">
              <xs:sequence>
                   <xs:element name="SECTION" type="SECTION" />
                   <xs:element name="TOWNSHIP" type="TOWNSHIP" />                                        
                   <xs:element name="TSHIP_DIR" type="TSHIP_DIR" />
                   <xs:element name="RANGE" type="RANGE" />
                   <xs:element name="RANGE_DIR" type="RANGE_DIR" />
                   <xs:element name="BASE_LN_MER" type="BASE_LN_MER" />
              </xs:sequence>
         </xs:complexType>
         <xs:complexType name="ag_application_data">
              <xs:complexContent>
                   <xs:extension base="application_data_abs">
                        <xs:sequence>                                             
                             <xs:element name="AER_GND_IND" type="AER_GND_IND" />
                             <xs:element name="SITE_LOC_ID" type="SITE_LOC_ID" />
                             <xs:element name="ACRE_PLANTED" type="ACRE_PLANTED" />
                             <xs:element name="UNIT_PLANTED" type="UNIT_PLANTED" />
                             <xs:element name="APPLIC_TM" type="APPLIC_TM" />
                             <xs:element name="FUME_CD" type="FUME_CD" />
                        </xs:sequence>
                   </xs:extension>
              </xs:complexContent>
         </xs:complexType>
         <xs:complexType name="nonag_application_data">
              <xs:complexContent>
                   <xs:extension base="application_data_abs">
                        <xs:sequence>                                        
                             <xs:element name="APPLIC_CNT" type="APPLIC_CNT" />
                             <xs:element name="LICENSE_NO" type="LICENSE_NO" />
                        </xs:sequence>
                   </xs:extension>
              </xs:complexContent>
         </xs:complexType>
         <!--- "Ag" -->
         <!--
              Type A:
              Data that would appear on individual lines
              in the old A type
              (F file type, agricultural job report)
              Type B:
              Data that would appear on individual lines
              in the old B type
              (F file type, agricultural monthly production summary)
         -->     
         <xs:complexType name="ag_application">
              <xs:complexContent>
                   <xs:extension base="application_abs">
                        <xs:sequence>                                        
                             <xs:element name="mtrs_data" type="mtrs_data" />
                             <xs:element name="application_data" type="ag_application_data" />
                        </xs:sequence>
                   </xs:extension>
              </xs:complexContent>
         </xs:complexType>
         <!--- "Non_Ag" -->     
         <!--
              Data that would appear on individual lines
              in the old C type
              (C file type, non-agricultural monthly summary)
         -->          
         <xs:complexType name="nonag_application">
              <xs:complexContent>
                   <xs:extension base="application_abs">
                        <xs:sequence>                                        
                             <xs:element name="application_data" type="nonag_application_data" />
                        </xs:sequence>
                   </xs:extension>
              </xs:complexContent>
         </xs:complexType>
         <!-- The individual lines of data that are transmitted. -->
         <xs:complexType name="data_lines">
              <xs:sequence>                                        
                   <xs:element name="Non_Ag" type="nonag_application" minOccurs="0" maxOccurs="unbounded"/>
                   <xs:element name="Ag" type="ag_application" minOccurs="0" maxOccurs="unbounded"/>                    
              </xs:sequence>
         </xs:complexType>
         <!-- !!!!!!!!! End Complex Types !!!!!!!!! -->
         <xs:element name="pur">     
              <xs:complexType>
                   <xs:sequence>               
                        <xs:element name="County" minOccurs="0" maxOccurs="1">
                             <!--
                                  Tag for counties to put county-specific
                                  data in (eg, their batch number, timestamp,
                                  contact info, etc)
                             -->
                        </xs:element>
                        <!-- File: information specific to the file -->               
                        <xs:element name="File" type="fileInfo" minOccurs="1" maxOccurs="1"/>
                        <!-- Data: lines of data transmitted -->
                        <xs:element name="Data" type="data_lines" minOccurs="1" maxOccurs="1"/>
                   </xs:sequence>
              </xs:complexType>
         </xs:element>
    </xs:schema>

  • XMLSig: validating an XML document incl. all certificates

    Hello,
    I have created a XML document signed with a certificate. I have added whole certification chain (first entry the users certificate, last CA) in the document:
    X509Data x509d = kif.newX509Data(Arrays.asList(myChain));
    ki = kif.newKeyInfo(Collections.singletonList(x509d));
    ...The document validates perfectly with XMLSignature.validate method but I am not sure if this method validates the certificates. I suppose not.
    Are there any standard processes to validate X509 certification chain from XML-signed document? Or do I have to retrive and verify all certificates myself? If so how? I have my very own KeySelector but I do not have idea how to use it to retreive my certificates:
        private static class X509CertKeySelector extends KeySelector {
            @SuppressWarnings({"LoopStatementThatDoesntLoop"})
            public KeySelectorResult select(KeyInfo keyInfo,
                                            KeySelector.Purpose purpose,
                                            AlgorithmMethod method,
                                            XMLCryptoContext context)
                    throws KeySelectorException {
                if (keyInfo == null) {
                    throw new KeySelectorException("Null KeyInfo object!");
                List list = keyInfo.getContent();
                for (Object aList : list) {
                    XMLStructure xmlStructure = (XMLStructure) aList;
                    if (xmlStructure instanceof X509Data) {
                        try {
                            X509Data xd = (X509Data) xmlStructure;
                            X509Certificate[] certs = (X509Certificate[]) xd.getContent().toArray(new X509Certificate[0]);
                            return new X509CertChainSelectorResult(certs);
                        } catch (ClassCastException e) {
                            throw new KeySelectorException("X509Data must contain X509 certificate list", e);
                    } else {
                        throw new KeySelectorException("KeyInfo doesn`t contain X509Data");
                throw new KeySelectorException("No KeyValue element found!");
        private static class X509CertChainSelectorResult implements KeySelectorResult {
            private X509Certificate[] certificates;
            X509CertChainSelectorResult(X509Certificate[] certs) {
                this.certificates = certs;
                for (X509Certificate c: certificates) {
                    System.out.println(c);
            public X509Certificate[] getCertificates() {
                return certificates;
            public Key getKey() {
                if (certificates != null && certificates.length > 0) {
                    PublicKey publicKey = certificates[0].getPublicKey();
                    return publicKey;
                } else
                    return null;
        }ps - the certificates are stored in BASE64 encoding, I would prefer something "nicer" XMLSig allows to store certificates in the XML-way... whats the trick to store the certification chain in the XML human-readable format?

    Verifying
    the chain (with the root certificate in a secure
    store) is only part of the whole verifying process.
    You also need to verify that the signature is over
    the correct data, and that the correct
    transformations have taken place. This is missing
    from the documentation. You might also need a CRL or
    other way to revoke certificates, depending on the
    usage of the library.Thank you but what you mean with correct data and transformation? XMLDigSig will do it for me, wont it? You are abolutely right with CRLs, in my TODO list... :-D

  • Validating an XML document using external DTD?

    Hi,
    I want to validate an XML file using external DTD with SAX parser.
    How can I validate an XML file with external DTD.
    Thanks in Advance,
    Mahendra

    I dont think we can set a DTD file throug java while
    parsing an XML.I've done it with an XML schema though. Can you use that instead? For schemas you do something like:
    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
    factory.setAttribute( "http://java.sun.com/xml/jaxp/properties/schemaSource",
                                       schemaUrl );where schemaUrl in this case would be something like file:///usr/local/whatever.xsd

  • Problem validating an XML document with a schema containing xs:include

    I have a problem using an include statement in xsd. I try to include another
    schema by using the include statement:
    <xsd:include schemaLocation="../../XXX.xsd"/>
    and get the xjc error:
    s4s-att-invalid-value: Invalid attribute value for 'schemaLocation' in element 'include': cvc-datatype-valid.1.2.1.
    Can anybody give me a hint what goes wrong here? THANKS!!!!
    ayache

    Your schemaLocation value is not a URI? To me, it looks like the value should conform to this:
    http://www.w3.org/TR/2004/REC-xmlschema-2-20041028/datatypes.html#anyURI
    I will let you read all those specs to see whether that is your problem.

  • Validating a XML document and skipping new lines ??

    Hi everybody !
    I'm currently developping a new application and the configuration is done within a XML file. My problem is that I'm using IP addresses and so users have to write things like this :
    <agentIP>
    132.137.43.2
    </agentIP>
    and I have a problem with the Java SAX parser : in fact I have declared the type of agentIP in a XML Schema like this :
    <xs:simpleType name="IPAddress">
    <xs:restriction base="xs:string">
    <xs:pattern value="((1?[0-9]?[0-9]|2[0-4][0-9]|25[0-5]).){3}(1?[0-9]?[0-9]|2[0-4][0-9]|25[0-5])"/>
    </xs:restriction>
    </xs:simpleType>and the problem is that if there are some white spaces before the IP or some new lines (in fact the user can format this XML file in different manners), I have a parsing error because the parser interprets these characters too.
    Has somebody any idea how to tell the parser to skip these characters ???
    for information here is my source code :
    ErrorHandler errorHandler = new MyErrorHandler();
        content.setLength(0);
        agentTable = new AgentTable();
        SAXParserFactory factory = SAXParserFactory.newInstance();
        factory.setNamespaceAware(true);
        factory.setValidating(true);
        SAXParser saxParser = null;
        try {
          saxParser = factory.newSAXParser();
        catch (ParserConfigurationException ex1) {
          ex1.printStackTrace();
        catch (SAXException ex1) {
          ex1.printStackTrace();
        try {
          saxParser.setProperty(JAXP_SCHEMA_LANGUAGE, W3C_XML_SCHEMA);
          try {
            saxParser.setProperty(
                "http://java.sun.com/xml/jaxp/properties/schemaSource",
                new org.xml.sax.InputSource(jamap.share.Constants.networkMap));
          catch (SAXNotRecognizedException ex4) {
          catch (SAXNotSupportedException ex4) {
        catch (SAXNotSupportedException ex3) {
          ex3.printStackTrace();
        catch (SAXNotRecognizedException ex3) {
          ex3.printStackTrace();
        org.xml.sax.XMLReader xmlReader = null;
        try {
          xmlReader = saxParser.getXMLReader();
        catch (SAXException ex) {
          ex.printStackTrace();
        xmlReader.setContentHandler(this);
        xmlReader.setErrorHandler(errorHandler);
        //    xmlReader.setProperty(
        //      "http://apache.org/xml/properties/schema/external-schemaLocation",
        //    new File("http://localhost:8080/agentfile.xml"));
        //xmlReader.setErrorHandler (new (ErrorHandler()));
        try {
          xmlReader.parse(new org.xml.sax.InputSource(jamap.share.Constants.homeDir +
                                                      jamap.share.Constants.
                                                      AgentFile));
        catch (SAXException ex2) {
          ex2.printStackTrace();
          System.out.println("Please correct your XML file !");
        catch (IOException ex2) {
          ex2.printStackTrace();
          System.out.println("Error in parsing the agent.xml file");
        return agentTable;
      public void startElement(java.lang.String uri,
                               java.lang.String localName,
                               java.lang.String qName,
                               Attributes attributes
                               ) throws
          SAXException {
        if (qName.equals("proxy")) {
          isAgentViaProxy = true;
        content.setLength(0);
      public void characters(char[] chars, int start, int len) throws SAXException {
        content.append(chars, start, len);
      public void ignorableWhitespace(char[] ch,
                                      int start,
                                      int length) throws SAXException {
        System.out.println("Some white spaces were ignored !");
      }and here the XML Schema used:
    <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
    <xs:simpleType name="IPAddress">
      <xs:restriction base="xs:string">
        <xs:pattern value="((1?[0-9]?[0-9]|2[0-4][0-9]|25[0-5]).){3}(1?[0-9]?[0-9]|2[0-4][0-9]|25[0-5])"/>
      </xs:restriction>
    </xs:simpleType>
    <xs:element name='networkMap'>
      <xs:complexType>
       <xs:sequence>
         <xs:element ref='agent' minOccurs='0' maxOccurs='unbounded'/>
       </xs:sequence>
      </xs:complexType>
    </xs:element>
    <xs:element name="agent">
      <xs:complexType>
       <xs:sequence>
         <xs:element name="ipAddress" type="IPAddress" minOccurs="1" maxOccurs="1" />
         <xs:element name="proxy" type="IPAddress" minOccurs="0" maxOccurs="1" />
       </xs:sequence>
      </xs:complexType>
    </xs:element>
    </xs:schema>THANK YOU...
    PA

    Hi !
    I've found the solution finally and as nobody wrote me I'll explain it...
    Basically to ignore white spaces you need to specify it within your XML Schema : here is an example of a possible description for an IPv6 address inside an XML schema :
    <xs:simpleType name="IPv6Address">
      <xs:restriction base="xs:string">
       <xs:whiteSpace value="collapse" fixed="true"/>
       <xs:pattern value="((1?[0-9]?[0-9]|2[0-4][0-9]|25[0-5]).){7}(1?[0-9]?[0-9]|2[0-4][0-9]|25[0-5])"/>
      </xs:restriction>
    </xs:simpleType>as you can see <xs:whiteSpace value="collapse" fixed="true"/> is solving the problem !!
    Bye..
    PA
    http://www.doffoel.com

  • Problem validating XMl document

    Hi everyone,
    I'm facing a problem validating a XML document with Apache toolkit under windows XP and eclipse 3.0
    I generate a pair of public/private keys using the RSA algorithm. The keys are of arbitrary length, but satisfying RSA conditions, ie we can encrypt and decrypt.
    I can sign my XML document, but no way to validate it. Validation is only ok when I generate random keys using the KeyPairGenerator.
    Do you think that arbitrary length keys don't allow to validate XML document. And do you have any idea how to solve the problem ( I'm not allowed to generate fixed length keys) ?
    Thansk a lot for your precious help.

    solved!
    urghh...forgot to load th eschema..duh. (must be friday)
    here's the fixed code:
        // parse the xml document (validate the xml string using a schema  file)
        // the xml document does not specified the System ID or location of
        // schema..and use no namespace
        public void parse(HandlerType type, String xmldoc) throws SAXException, IOException {
            File           schema      = schemaMap.get(type);
            DefaultHandler handler     = handlerMap.get(yype);
            XMLReader   reader = XMLReaderFactory.createXMLReader(VENDOR);
            InputSource source = new InputSource(new StringReader(xmldoc));
            reader.setContentHandler(handler);
            reader.setFeature("http://xml.org/sax/features/validation", true);
            reader.setFeature("http://apache.org/xml/features/validation/schema", true);
            reader.setFeature("http://apache.org/xml/features/validation/schema-full-checking", true);
            reader.setProperty("http://apache.org/xml/properties/schema/external-noNamespaceSchemaLocation",
            "file:///" + schema.getAbsolutePath());
            reader.parse(source);          
        }

  • Sign XML document without KeyPairGenerator

    Hi everyone -----> System.out.println("HEEEELP!");
    I have a problem for signing and validating an XML document, using the Apache toolkit and JWSDP.
    Example :
    XMLSignature signature = fac.unmarshalXMLSignature(valContext);
    boolean coreValidity = signature.validate(valContext);
    When I genreate keys with KeyPairGenerator, everything works fine (The KeyPairGenerator uses crt coefficient). But If I use my own RSA keys (modulus, private and public exponent), I can sign but not validate the XML document, ie the signature value of the signedInfo. Strange thing : I'm sure the keys are correct. I can encyrpt and decrypt messages using my own validation program with these keys.
    Does anyone know how to sign and validate XML documents with its own keys ?
    I can reply more details if necessary ...
    Any help would be very very appreciated :)

    You're putting words in my mouth, I never mentioned DOM.
    What I'm saying is that JAXB is not of concern to your requirements. Whatever happens to the objects after they are created from XML is up to you. It has done its job, the XML has been transformed into object set A. Perhaps at some point in time it can do some more work for you, when you have an object set B that need to be written to an XML structure. How you get from A to B, that's up to you.
    But perhaps there is a more suited tool for the job that actually deals with XML transformations (hint hint). You could probably hack something together with basic SAX. Heck, if all you want to do is replace easy to identify lines of data with other lines of data a BufferedReader/BufferedWriter could already work.

  • Invalid testsuite XML document for junitreport task

    Hi everyone, I'm new to this forum and apologies if this is the incorrect place for me to post this thread. Basically I'm having some issues with the junitreport task with my junit test project.
    I have a dummy class called Money and dummy test suite called MoneyTest that contains 4 test cases. The test is run through ANT <junit> task and they all passed with no problems. The problem occurred when I tried to perform the automatic test report generation using <junitreport> task, and the generated HTML pages contain no test results at all, indicated by "Tests:0 Failures:0 Errors:0 Success rate:0 Time:0.000" (in which case it should be 4 for Tests, etc.).
    The error message says "TESTS-TestSuites.xml is not a valid testsuite XML document". I assume this file is auto-generated by the <junitreport> task which defines how the output HTML should look like. However, it only contains the folloing 2 lines:<?xml version="1.0"?> <testsuites />. I suspect this should be the cause of the empty output. So could anyone who's familar with this issue shed any light on how I should go about deal with this issue please? Thank you very much in advance!
    By the way, the task code in build.xml for reporting is as follows:
    <target name="report">
         <junitreport todir="./reports">
              <fileset dir="./reports" includes="*.xml" />
              <report format="frames" todir="./report/html" />
         </junitreport>
    </target>

    Thanks, the issue has been solved. I simply forgot to set the formatter type to xml in the junit task.

  • Validating XML documents against a DTD

    Guys I am new to XML and I have this requirement to validate a XML document against a DTD.This validation has to be done through my java application.In short , a user enters a XML data thru a JSP form ,and moment he presses the SAVE button my java program should validate the XML data against a DTD and then display any error or else save the data into an Oracle table.
    I was wondering lot of program/utitlities must be available out there which will do the validation for me ,rather than me re-inventing the wheel.
    Please advice.
    Thanks
    Manohar.

    You should go through this to learn more on XML with Java :
    http://www.onjava.com/pub/a/onjava/excerpt/learnjava_23/index1.html
    You can check following how to to parse XML doc against a schema
    http://otn.oracle.com/sample_code/tech/java/codesnippet/xdk/SchemaValidation/SchemaValidation.html
    You should also look at chapter 4 of following doc for parsing XML using java :
    http://download-west.oracle.com/docs/cd/B10501_01/appdev.920/a96621/toc.htm
    Chandar

  • XML SAX dtd Validation Problem

    Hi,
              I’m having problems getting an xml document to validate within Weblogic 8.1. I am trying to parse a document that references both a dtd and xsd. Both the schema and dtd reference need to be substituted so they use local paths. I specify the schema the parser should use and have created an entityResolver to change the dtd reference.
              When this runs as a standalone app from eclipse the file parses and validates without a problem. When deployed to the app server the process seems to be unable read the contents of the dtd. Its not that it cannot find the file (no FileNotFoundException is thrown but this can be created if I delete the dtd) rather it seems to find no declared elements.
              Initial thought was that the code didn’t have access to read the dtd from its location on disk, to check I moved the dtd to within the deployed war and reference as a resource. The problem still persists.
              Code Snippet:
              boolean isValid = false;
              try {
              // Create and configure factory
              SAXParserFactory factory = SAXParserFactoryImpl.newInstance();
              factory.setValidating(true);
              factory.setNamespaceAware(true);
              // To be notified of validation errors in the XML document,
              // add a custom error handler to the document builder
              PIMSFeedFileValidationHandler handler
              = new PIMSFeedFileValidationHandler();
              // Create and Configure Parser
              SAXParser parser = factory.newSAXParser();
              parser.setProperty(JAXP_SCHEMA_LANGUAGE, W3C_XML_SCHEMA);
              parser.setProperty(NAMESPACE_PROPERTY_KEY, getSchemaFilePath());
              // Set reader with entityResolver for dtd
              XMLReader xmlReader = parser.getXMLReader();
              xmlReader.setEntityResolver(new SAXEntityResolver(this.dtdPath));
              // convert file to URL, as it is a remote file
              URL url = super.getFile().toURL();
              // Open an input stream and parse
              InputStream is = url.openStream();
              xmlReader.setErrorHandler(handler);
              xmlReader.parse(new InputSource(is));
              is.close();
              // get the result of parsing the document by checking the
              // errorhandler's isValid property
              isValid = handler.isValid();
              if (!isValid) {
              LOGGER.warn(handler.getMessage());
              LOGGER.debug("XML file is valid XML? " + isValid);
              } catch (ParserConfigurationException e) {
              LOGGER.error("Error parsing file", e);
              } catch (SAXException e) {
              LOGGER.error("Error parsing file", e);
              } catch (IOException e) {
              throw new FeedException(e);
              return isValid;
              See stack trace below for a little more info.
              2005-01-28 10:24:09,217 [DEBUG] [file] - Attempting validation of file 'cw501205.wa1.xml' with schema at 'C:/pims-feeds/hansard/schema/hansard-v1-9.xsd'
              2005-01-28 10:24:09,217 [DEBUG] [file] - Entity Resolver is using DTD path file:C:/Vignette/runtime_services/8.1/install/common/nodemanager/
              VgnVCMServer/stage/pims-hansard/pims-hansard.war/WEB-INF/classes/com/morse/pims/cms/feed/sax/ISO-Entities.dtd
              2005-01-28 10:24:09,227 [DEBUG] [file] - Creating InputSource at: file:C:/Vignette/runtime_services/8.1/install/common/nodemanager/VgnVCMServer/stage/pims-hansard/pims-hansard.war/WEB-INF/classes/com/morse/pims/cms/feed/sax/ISO-Entities.dtd
              2005-01-28 10:24:09,718 [WARN ] [file] - org.xml.sax.SAXParseException: Element type "Hansard" must be declared.
              org.xml.sax.SAXParseException: Element type "Session" must be declared.
              org.xml.sax.SAXParseException: Element type "DailyRecord" must be declared.
              org.xml.sax.SAXParseException: Element type "Volume" must be declared.
              org.xml.sax.SAXParseException: Element type "Written" must be declared.
              org.xml.sax.SAXParseException: Element type "WrittenHeading" must be declared.
              org.xml.sax.SAXParseException: Element type "Introduction" must be declared.
              … continues for all the elements in the doc
              2005-01-28 10:24:10,519 [DEBUG] [file] - XML file is valid XML? false
              2005-01-28 10:24:10,519 [WARN ] [file] - Daily Part file 'cw501205.wa1.xml' was not valid XML and was not processed.
              Has anybody seen this behavior before with weblogic and if so how have you resolved the issue.
              Thanks in Advance
              Adam

    It looks like you clicked on "Post" before you got around to explaining your problem. I don't see any error messages or any description of what was supposed to happen and what happened instead.
    Now, I don't know anything about XML Schema, but just guessing at how that unique name feature might be designed, and just guessing that your unique name is actually in the <userId> element, I would suggest that this:
    <xsd:unique name="un_name"> 
      <xsd:selector xpath="USER"/> 
      <xsd:field xpath="."/> 
    </xsd:unique> is at fault because it doesn't mention the <userId> element anywhere.

  • Problem when trying to load an XML document with DTD or XML SCHEMA

    Hello
    I have tried to load an XML document in Data Services, and I created the xsd file and Dtd file. (With altova xml spy software automatically) to import into SAP Data Services 3.2. .
    In Data Services I created the dtd import file DTD and then called the XML file from the DTD (the xml file is validated vs the dtd file), and I could not read the xml correctly because it tells me that an ELEMENT called <item> expected joiners who did not come in the structure of import (dtd), but if the xml.
    I understand that the document root is the label: CUSTOMER_FULL_2014, the data flow is as follows:CARGA_XML_CUSTOMER |
    Turns out the joiners element is used to separate the xml elements are repeated, but is used at different levels. My idea is that the design will dtd second, or something I'm missing or is incorrectly stated.
    Thank you.
    xml
    +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    <?xml version="1.0" encoding="utf-8"?>
    <CUSTOMER_FULL_2014>
      <item>
      <CUST_NO>202222</CUST_NO>
      <ADDRESS>
      <item>
      <SHIP_TO>202222</SHIP_TO>
      <NAME1>Henley.</NAME1>
      <STREET>Vitacura #40</STREET>
      <CITY>LIMA</CITY>
      </item>
      </ADDRESS>
      <EQUIPMENT>
      <item>
      <EQUI_NO>81623</EQUI_NO>
      </item>
      <item>
      <EQUI_NO>81633</EQUI_NO>
      </item>
      <item>
      <EQUI_NO>81993</EQUI_NO>
      </item>
      <item>
      <EQUI_NO>82003</EQUI_NO>
      </item>
      <item>
      <EQUI_NO>82013</EQUI_NO>
      </item>
      <item>
      <EQUI_NO>82103</EQUI_NO>
      </item>
      <item>
      <EQUI_NO>82113</EQUI_NO>
      </item>
      <item>
      <EQUI_NO>581203</EQUI_NO>
      </item>
      <item>
      <EQUI_NO>900003-EMER</EQUI_NO>
      </item>
      <item>
      <EQUI_NO>9000033-STOCK</EQUI_NO>
      </item>
      </EQUIPMENT>
      <STORAGE_LOC>
      <item>
      <STOR_LOC_NO>0001</STOR_LOC_NO>
      <DESCRIPTION>01 Parts Center</DESCRIPTION>
      </item>
      <item>
      <STOR_LOC_NO>0056</STOR_LOC_NO>
      <DESCRIPTION>56 henley</DESCRIPTION>
      </item>
      </STORAGE_LOC>
      </item>
      <item>
      <CUST_NO>2007933434343</CUST_NO>
      <ADDRESS>
      <item>
      <SHIP_TO>2007933434343</SHIP_TO>
      <NAME1>Campos de Almacenaje SA</NAME1>
      <STREET>Calacoto2, Calle 1</STREET>
      <HOUSE_NO>Piso 1</HOUSE_NO>
      <CITY>La Paz</CITY>
      </item>
      </ADDRESS>
      <EQUIPMENT>
      <item>
      <EQUI_NO>90000-EMER</EQUI_NO>
      </item>
      <item>
      <EQUI_NO>90000333-STOCK</EQUI_NO>
      </item>
      </EQUIPMENT>
      <STORAGE_LOC>
      <item>
      <STOR_LOC_NO>00012</STOR_LOC_NO>
      <DESCRIPTION>01 Parts Center</DESCRIPTION>
      </item>
      <item>
      <STOR_LOC_NO>0056</STOR_LOC_NO>
      <DESCRIPTION>56 henley</DESCRIPTION>
      </item>
      </STORAGE_LOC>
      </item>
      <item>
      <CUST_NO>200801333</CUST_NO>
      <ADDRESS>
      <item>
      <SHIP_TO>200801333</SHIP_TO>
      <NAME1>CONSTRUCTORA SA.</NAME1>
      <STREET>Ruta Panamericana Km 100</STREET>
      <CITY>San Antonio 23</CITY>
      </item>
      </ADDRESS>
      <EQUIPMENT>
      <item>
      <EQUI_NO>1507933</EQUI_NO>
      </item>
      <item>
      <EQUI_NO>1509733</EQUI_NO>
      </item>
      <item>
      <EQUI_NO>90000-EMER</EQUI_NO>
      </item>
      <item>
      <EQUI_NO>90000333-STOCK</EQUI_NO>
      </item>
      </EQUIPMENT>
      <STORAGE_LOC>
      <item>
      <STOR_LOC_NO>0001</STOR_LOC_NO>
      <DESCRIPTION>01 Parts Center</DESCRIPTION>
      </item>
      <item>
      <STOR_LOC_NO>0056</STOR_LOC_NO>
      <DESCRIPTION>56 henley</DESCRIPTION>
      </item>
      </STORAGE_LOC>
      </item>
    </CUSTOMER_FULL_2014>
    ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    ARCHIVO DTD CREADO (automáticamente con xml spy)
    <?xml version="1.0" encoding="UTF-8"?>
    <!-- DTD generado con XMLSpy v2014 rel. 2 (x64) (http://www.altova.com) -->
    <!ELEMENT CITY (#PCDATA)>
    <!ELEMENT item ((SHIP_TO, NAME1, STREET, HOUSE_NO?, CITY) | (CUST_NO, ADDRESS, EQUIPMENT, STORAGE_LOC) | (STOR_LOC_NO, DESCRIPTION) | EQUI_NO)>
    <!ELEMENT NAME1 (#PCDATA)>
    <!ELEMENT STREET (#PCDATA)>
    <!ELEMENT ADDRESS (item)>
    <!ELEMENT CUST_NO (#PCDATA)>
    <!ELEMENT EQUI_NO (#PCDATA)>
    <!ELEMENT SHIP_TO (#PCDATA)>
    <!ELEMENT HOUSE_NO (#PCDATA)>
    <!ELEMENT EQUIPMENT (item+)>
    <!ELEMENT DESCRIPTION (#PCDATA)>
    <!ELEMENT STORAGE_LOC (item+)>
    <!ELEMENT STOR_LOC_NO (#PCDATA)>
    <!ELEMENT CUSTOMER_FULL_2014 (item+)>
    ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    The error of MONITOR Data Services
    11676
    5184
    XML-240108
    11-04-2014 17:34:16
    |Data flow CARGA_XML_CUSTOMER|Reader READ MESSAGE customer OUTPUT(customer)
    11676
    5184
    XML-240108
    11-04-2014 17:34:16
    An element named <item> present in the XML data input does not exist in the XML format used to set up this XML source in data
    11676
    5184
    XML-240108
    11-04-2014 17:34:16
    flow <CARGA_XML_CUSTOMER>. Please validate your XML data.
    11676
    5184
    XML-240307
    11-04-2014 17:34:16
    |Data flow CARGA_XML_CUSTOMER|Reader READ MESSAGE customer OUTPUT(customer)
    11676
    5184
    XML-240307
    11-04-2014 17:34:16
    XML parser failed: See previously displayed error message.
    The Error from Monitor
    The metadata DTD
    Thanks
    Juan

    Hi Juan Juan,
    I generated a new XSD file using MS Visual Studio based on your XML file.
    The empty spaces in the source is replaced with <Null> in the target table.
    Here is the XSD:
    <?xml version="1.0" encoding="utf-8"?>
    <xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
        <xs:element name="CUSTOMER_FULL_20140207_033015_001">
            <xs:complexType>
                <xs:sequence>
                    <xs:choice maxOccurs="unbounded">
                        <xs:element name="CUST_NO" type="xs:unsignedInt" />
                        <xs:element name="ADDRESS">
                            <xs:complexType>
                                <xs:sequence>
                                    <xs:element name="SHIP_TO" type="xs:unsignedInt" />
                                    <xs:element name="NAME1" type="xs:string" />
                                    <xs:element name="STREET" type="xs:string" />
                                    <xs:element minOccurs="0" name="HOUSE_NO" type="xs:string" />
                                    <xs:element name="CITY" type="xs:string" />
                                </xs:sequence>
                            </xs:complexType>
                        </xs:element>
                        <xs:element name="EQUIPMENT">
                            <xs:complexType>
                                <xs:sequence>
                                    <xs:element maxOccurs="unbounded" name="EQUI_NO" type="xs:string" />
                                </xs:sequence>
                            </xs:complexType>
                        </xs:element>
                        <xs:element name="STORAGE_LOC">
                            <xs:complexType>
                                <xs:sequence>
                                    <xs:choice maxOccurs="unbounded">
                                        <xs:element name="STOR_LOC_NO" type="xs:unsignedByte" />
                                        <xs:element name="DESCRIPTION" type="xs:string" />
                                    </xs:choice>
                                </xs:sequence>
                            </xs:complexType>
                        </xs:element>
                    </xs:choice>
                </xs:sequence>
            </xs:complexType>
        </xs:element>
    </xs:schema>
    For Source XML
    <?xml version="1.0" encoding="utf-8"?>
    <CUSTOMER_FULL_20140207_033015_001>
      <CUST_NO>200530</CUST_NO>
      <ADDRESS>
      <SHIP_TO>903533</SHIP_TO>
      <NAME1>HENLEY - PART MAQUINARIAS S.A.</NAME1>
      <STREET>Dean Camilo # 148, San Carlos</STREET>
      <CITY>LIMA</CITY>
      </ADDRESS>
      <EQUIPMENT>
      <EQUI_NO>4442</EQUI_NO>
      <EQUI_NO>8163</EQUI_NO>
      <EQUI_NO>8199</EQUI_NO>
      <EQUI_NO>8200</EQUI_NO>
      <EQUI_NO>8201</EQUI_NO>
      <EQUI_NO>8210</EQUI_NO>
      <EQUI_NO>8211</EQUI_NO>
      <EQUI_NO>58120</EQUI_NO>
      <EQUI_NO>90000-EMERGENCY</EQUI_NO>
      <EQUI_NO>90000-STOCK</EQUI_NO>
      </EQUIPMENT>
      <STORAGE_LOC>
      <STOR_LOC_NO>0001</STOR_LOC_NO>
      <DESCRIPTION>01 Parts Center</DESCRIPTION>
      <STOR_LOC_NO>0056</STOR_LOC_NO>
      <DESCRIPTION>56 HEN</DESCRIPTION>
      </STORAGE_LOC>
      <CUST_NO>200793</CUST_NO>
      <ADDRESS>
      <SHIP_TO>200793</SHIP_TO>
      <NAME1>Minera San Cristobal S.A.</NAME1>
      <STREET>Calacoto, Calle 90, Torre 2</STREET>
      <HOUSE_NO>Piso 5</HOUSE_NO>
      <CITY>La Paz</CITY>
      </ADDRESS>
      <EQUIPMENT>
      <EQUI_NO>90000-EMERGENCY</EQUI_NO>
      <EQUI_NO>90000-STOCK</EQUI_NO>
      </EQUIPMENT>
      <STORAGE_LOC>
      <STOR_LOC_NO>0001</STOR_LOC_NO>
      <DESCRIPTION>01 Parts Center</DESCRIPTION>
      <STOR_LOC_NO>0056</STOR_LOC_NO>
      <DESCRIPTION>56 HEN</DESCRIPTION>
      </STORAGE_LOC>
      <CUST_NO>200801</CUST_NO>
      <ADDRESS>
      <SHIP_TO>200801</SHIP_TO>
      <NAME1>ISEMAR S.A.</NAME1>
      <STREET>Ruta Km 28.45</STREET>
      <CITY>Don Torcuato Paraguay</CITY>
      </ADDRESS>
      <EQUIPMENT>
      <EQUI_NO>15079</EQUI_NO>
      <EQUI_NO>15097</EQUI_NO>
      <EQUI_NO>90000-EMERGENCY</EQUI_NO>
      <EQUI_NO>90000-STOCK</EQUI_NO>
      </EQUIPMENT>
      <STORAGE_LOC>
      <STOR_LOC_NO>0001</STOR_LOC_NO>
      <DESCRIPTION>01 Parts Center</DESCRIPTION>
      <STOR_LOC_NO>0056</STOR_LOC_NO>
      <DESCRIPTION>56 HEN</DESCRIPTION>
      </STORAGE_LOC>
    </CUSTOMER_FULL_20140207_033015_001>
    Output:
    Regards,
    Akhileshkiran.

  • Creation of a XML Document with DTD entry

    I am trying to create a XML file on the fly. I use the
    NodeFactory to contruct a document (createDocument()). I have
    then setStandalone("no") and setVersion("1.0"). when I try to
    add a DOCTYPE node via appendChild( new XMLNode("test",
    Node.DOCUMENT_TYPE_NODE)), I get a ClassCastException.
    This is using the 1.0.1.1.0 xml parser.
    What is the mechanism to add a node of this type? I noticed that
    the NodeFactory did not have a machanism for creating a DOCTYPE
    node.
    null

    Nestor Dutko (guest) wrote:
    : I am trying to create a XML file on the fly. I use the
    : NodeFactory to contruct a document (createDocument()). I have
    : then setStandalone("no") and setVersion("1.0"). when I try to
    : add a DOCTYPE node via appendChild( new XMLNode("test",
    : Node.DOCUMENT_TYPE_NODE)), I get a ClassCastException.
    : This is using the 1.0.1.1.0 xml parser.
    : What is the mechanism to add a node of this type? I noticed
    that
    : the NodeFactory did not have a machanism for creating a DOCTYPE
    : node.
    There is no mechanism to create a new DOCUMENT_TYPE_NODE object
    via DOM APIs. The only way to get a DTD object is to parse the
    DTD file or the XML file using the DOMParser, and then use the
    getDocType() method. Note that new XMLNode("test",
    Node.DOCUMENT_TYPE_NODE) does not create a DTD
    object. It creates an XMLNode object with the type set to
    DOCUMENT_TYPE_NODE, which infact should not be allowed. The
    ClassCastException is raised because appendChild expects a DTD
    object (based on the type).
    Also, we do not do any validation while creating the DOM tree
    using the DOM APIs. So setting the DTD in the Document will not
    help in validating the DOM tree that is constructed. The only way
    to validate an XML file is to parse the XML document using
    DOMParser or SAXParser.
    Oracle XML Team
    http://technet.oracle.com
    Oracle Technology Network
    null

Maybe you are looking for

  • Call to ldap server fails ORA-06521: PL/SQL: Error mapping function

    I am getting this error(s) ORA-06521: PL/SQL: Error mapping function ORA-06512: at "SYS.DBMS_LDAP_API_FFI", line 0 ORA-06512: at "SYS.DBMS_LDAP", line 1338 ORA-06512: at "SYS.DBMS_LDAP", line 1273 ORA-06512: at "SYS.DBMS_LDAP", line 529 ORA-06512: at

  • IDoc - Segment Details for Confirmation Code

    Hi Friends, I am doing Purchase Order Acknowledgement(855) - Inbound Scenario. I need the ConfirmationCode and Confirmation ControlKey fields in the segement of basic type ORDERS05. We couldnt find these two fields in the segments, can any one help m

  • Can't get rid of first line indent

    I am fairly new to InDesign. I have a text box in which I want to have 3 centered tabs. The first line, whether tabbed to 1st tab stop or not, is indented approximately 1/2 inch. No indent displays in the paragraph format window or in the tab stops w

  • Message Class - Validation

    Hi Message class can it be transpoted without release(Transport request) to other clients. ???? The problem is ,once the message class is created & released, not in a postion to add any new messages . For any new requirement ,new message class  is be

  • Technical Communications Suite Online Training Library

    Has anyone used Technical Communications Suite Online Training Library?  It's become very apparent that in order for me to be productive quickly using FrameMaker 9 and the rest of the applications in the Technical Communications Suite, I need some fo