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>

Similar Messages

  • 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 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.

  • Using java to fill in the blanks in an xml document via a schema

    Hi all
    What im trying to do is basically take an xml document and run it through a xml schema validator and then if the xsd has any default values to basically populate the original xml document with these default values
    e.g.
    <root>
    <name>dave</name>
    <name></name>
    </root>
    the schema would be something like
    <xs:element name="name" default="bobby">
    after schema validation i would want the document to be
    <root>
    <name>dave</name>
    <name>bobby</name>
    </root>
    is that something possible to do in java with any specific xml frameworks out there? if so can any one give me any pointers in the right direction?

    i assume by the lack of response this cannot be done then :(

  • 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.

  • 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

  • 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

  • How to store xml document in d/b using jsp

    hai,
    Iam doing one web application in JSP, i have a requirement to store the xml document in database. We have to use some xml parsers, so can anyone please give me the related code in JSP.
    regards,
    Praveen Vinnakota.

    If you have to store the Whole XML Document then I don't think you need to mess with XML Parsers. I mean simply the XML File in the Database Field where it has to stored
    Bye for now
    CSJakharia

  • 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

  • Validation of xml agaist XSD in by using schemaValidate of oraxsd

    Hi,
    I am trying to validate an xml agaist xsd from pro*C wher i have oraxml and oraxsd libraries.
    I have used a method of oraxsd and it gives error 14. pLesa let me know why i am getting this eror and how i can validate an xml by using thses functions..
    int validateXSD()
    xsdctx *ctx1;
    xmlctx *ctx ;
    uword ecode1 ;
    xmlnode *root;
         if(gold_debug)
                   printf("Validate XSD");               
                   fflush(stdout);
              root = getDocumentElement(ctx);          
              if(gold_debug)
                   printf("Validate XSD *****1 ");               
                   fflush(stdout);
              ctx1 = schemaInitialize(ctx, &ecode1);          
              if (ctx1==0 ) {
                   fprintf(stderr,"XSD initialisation failed\n");
                   return 1;
              if(ecode1 = schemaValidate(ctx1, root, (oratext *)xsdfile)) {
              if(gold_debug)
                        printf("Validation failed, error %u\n", ecode1);               
                        fflush(stdout);
                   return 1;
              }else{
                   if(gold_debug)
                        printf("*******************Scheam Validation Success*****************");               
                        fflush(stdout);
         schemaTerminate(ctx1);      
              return 0;
    output is
    Validate XSD *****1
    Validation failed, error 14
    Thanks,
    Nisa

    For performance reasons the CLOB (hopefully XMLType based) is the wrong way to go. Have a look at XMLType Object Relational or Binary XML storage model.
    1) The info needed can be found in the manual under "Schema evolution" and depending on your version you can use in-place or copy-evolve
    2) "other way of validating" would be what / how ? Please elaborate.
    3) Yep, you could. But doing it the XMLDB Oracle way would be more efficient, for example one parse only and then pinned in memory... Why would you simulate what Oracle already has optimized for you and ready to use...?

  • Extract xml file with rowset schema using plsql

    I want to extract the rowsheet data from an xml file using plsql database procedure
    Here is an example of the xml file:
    <xml xmlns:s='uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882'
         xmlns:dt='uuid:C2F41010-65B3-11d1-A29F-00AA00C14882'
         xmlns:rs='urn:schemas-microsoft-com:rowset'
         xmlns:z='#RowsetSchema'>
    <s:Schema id='RowsetSchema'>
         <s:ElementType name='row' content='eltOnly'>
              <s:AttributeType name='Sheet_Number' rs:number='1' rs:maydefer='true' rs:writeunknown='true'>
                   <s:datatype dt:type='int' dt:maxLength='4' rs:precision='10' rs:fixedlength='true'/>
              </s:AttributeType>
              <s:AttributeType name='Appl_Number1' rs:number='2' rs:maydefer='true' rs:writeunknown='true'>
                   <s:datatype dt:type='int' dt:maxLength='4' rs:precision='10' rs:fixedlength='true'/>
              </s:AttributeType>
              <s:AttributeType name='Rating1' rs:number='3' rs:nullable='true' rs:maydefer='true' rs:writeunknown='true'>
                   <s:datatype dt:type='string' dt:maxLength='25'/>
              </s:AttributeType>
              <s:AttributeType name='Criteria1' rs:number='4' rs:nullable='true' rs:maydefer='true' rs:writeunknown='true'>
                   <s:datatype dt:type='string' dt:maxLength='25'/>
              </s:AttributeType>
              <s:AttributeType name='Appl_Number2' rs:number='5' rs:maydefer='true' rs:writeunknown='true'>
                   <s:datatype dt:type='int' dt:maxLength='4' rs:precision='10' rs:fixedlength='true'/>
              </s:AttributeType>
              <s:AttributeType name='Rating2' rs:number='6' rs:nullable='true' rs:maydefer='true' rs:writeunknown='true'>
                   <s:datatype dt:type='string' dt:maxLength='25'/>
              </s:AttributeType>
              <s:AttributeType name='Criteria2' rs:number='7' rs:nullable='true' rs:maydefer='true' rs:writeunknown='true'>
                   <s:datatype dt:type='string' dt:maxLength='25'/>
              </s:AttributeType>
              <s:extends type='rs:rowbase'/>
         </s:ElementType>
    </s:Schema>
    <rs:data>
         <z:row Sheet_Number='32486' Appl_Number1='198970' Rating1='-2' Criteria1='RTG' Appl_Number2='198989' Rating2='5'
              Criteria2='RTG'/>
         <z:row Sheet_Number='12345' Appl_Number1='198970' Rating1='-3' Criteria1='RTG' Appl_Number2='198989' Rating2='3'
              Criteria2='RTG'/>
    </rs:data>
    </xml>
    I need to extract the values from all of the columns : sheet_number, appl_number1, rating1, criteria1, appl_number2, rating2, criteria2. Validate the data and insert into oracle tables.
    I'm having dificulties extrating the data from the "z:row" recordset
    Can anyone help with the syntax ?
    I'm use to extracting with tags using syntax like this
    declare
    v_xml_content XMLTYPE;
    begin
    v_xml_content := db_get_xml_from_file (p_file_name, p_directory, 'ISO-8859-1');
    FOR f IN (SELECT value(x) file_data
    FROM TABLE
    (xmlsequence
    (extract (v_xml_content,'/data'))) x) LOOP
    SELECT extractvalue(f.file_data,'/data/row') into v_row from dual;                                                                      END LOOP;

    I want to extract the rowsheet data from an xml file using plsql database procedure
    Here is an example of the xml file:
    <xml xmlns:s='uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882'
         xmlns:dt='uuid:C2F41010-65B3-11d1-A29F-00AA00C14882'
         xmlns:rs='urn:schemas-microsoft-com:rowset'
         xmlns:z='#RowsetSchema'>
    <s:Schema id='RowsetSchema'>
         <s:ElementType name='row' content='eltOnly'>
              <s:AttributeType name='Sheet_Number' rs:number='1' rs:maydefer='true' rs:writeunknown='true'>
                   <s:datatype dt:type='int' dt:maxLength='4' rs:precision='10' rs:fixedlength='true'/>
              </s:AttributeType>
              <s:AttributeType name='Appl_Number1' rs:number='2' rs:maydefer='true' rs:writeunknown='true'>
                   <s:datatype dt:type='int' dt:maxLength='4' rs:precision='10' rs:fixedlength='true'/>
              </s:AttributeType>
              <s:AttributeType name='Rating1' rs:number='3' rs:nullable='true' rs:maydefer='true' rs:writeunknown='true'>
                   <s:datatype dt:type='string' dt:maxLength='25'/>
              </s:AttributeType>
              <s:AttributeType name='Criteria1' rs:number='4' rs:nullable='true' rs:maydefer='true' rs:writeunknown='true'>
                   <s:datatype dt:type='string' dt:maxLength='25'/>
              </s:AttributeType>
              <s:AttributeType name='Appl_Number2' rs:number='5' rs:maydefer='true' rs:writeunknown='true'>
                   <s:datatype dt:type='int' dt:maxLength='4' rs:precision='10' rs:fixedlength='true'/>
              </s:AttributeType>
              <s:AttributeType name='Rating2' rs:number='6' rs:nullable='true' rs:maydefer='true' rs:writeunknown='true'>
                   <s:datatype dt:type='string' dt:maxLength='25'/>
              </s:AttributeType>
              <s:AttributeType name='Criteria2' rs:number='7' rs:nullable='true' rs:maydefer='true' rs:writeunknown='true'>
                   <s:datatype dt:type='string' dt:maxLength='25'/>
              </s:AttributeType>
              <s:extends type='rs:rowbase'/>
         </s:ElementType>
    </s:Schema>
    <rs:data>
         <z:row Sheet_Number='32486' Appl_Number1='198970' Rating1='-2' Criteria1='RTG' Appl_Number2='198989' Rating2='5'
              Criteria2='RTG'/>
         <z:row Sheet_Number='12345' Appl_Number1='198970' Rating1='-3' Criteria1='RTG' Appl_Number2='198989' Rating2='3'
              Criteria2='RTG'/>
    </rs:data>
    </xml>
    I need to extract the values from all of the columns : sheet_number, appl_number1, rating1, criteria1, appl_number2, rating2, criteria2. Validate the data and insert into oracle tables.
    I'm having dificulties extrating the data from the "z:row" recordset
    Can anyone help with the syntax ?
    I'm use to extracting with tags using syntax like this
    declare
    v_xml_content XMLTYPE;
    begin
    v_xml_content := db_get_xml_from_file (p_file_name, p_directory, 'ISO-8859-1');
    FOR f IN (SELECT value(x) file_data
    FROM TABLE
    (xmlsequence
    (extract (v_xml_content,'/data'))) x) LOOP
    SELECT extractvalue(f.file_data,'/data/row') into v_row from dual;                                                                      END LOOP;

  • How to get the WHOLE xml document inside a string using XSLT mapping

    Hi folks,
    I have a deep xml structure that I want to embed as body, tags included, in a mail message (not as an attachment).
    I'm trying to use Michal's method in this blog
    /people/michal.krawczyk2/blog/2005/11/01/xi-xml-node-into-a-string-with-graphical-mapping
    However, I can't get it to deliver the entire structure instead of just specific elements.
    Any help is greatly appreciated,
    Thanks,
    Guy

    Ashok,
    I was able to work it out for my case.
    This XSL......
    <?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:template match="/">
    <inside>
    <namestring>
    <xsl:text disable-output-escaping="yes"><![CDATA[<![CDATA[]]></xsl:text>
    <xsl:copy-of select="outside/name/*"/>
    <xsl:text disable-output-escaping="yes"><![CDATA[]]]]></xsl:text>
    <xsl:text disable-output-escaping="yes"><![CDATA[>]]></xsl:text>
    </namestring>
    </inside>
    </xsl:template>
    </xsl:stylesheet>
    ...will transform this input....
    <?xml version="1.0" encoding="UTF-8"?>
    <outside>
    <name>
    <nameone>name1</nameone>
    <nametwo>name2</nametwo>
    <namethree>name3</namethree>
    </name>
    </outside>
    ...and put the whole lot into the CDATA element.
    Hope this helps you,
    Guy

  • Validating XML against an XML Schema using PL/SQL

    Hello everyone,
    I've a strange problem.
    I'm trying to validate an XMLTYPE variable against an XSD schema using the XMLisValid function.
    The XML I was trying to validate was returning false (0) when using this method.
    However, when I register the XSD against a column in a table and then insert this XMLTYPE into that column, I do not get any errors. If I change the XSD to ensure failure when using this method, I do get an error, so it is registered and working.
    I have then created a very basic XSD and both methods work when validating the XML against this. So obviously the more complicated XSD I want to validate against is making a difference, but I would expect them to either both fail or both pass, not one fail and one pass.
    Does anyone know why they'd be returning different results?
    Thanks in advance for your help.
    Robin
    examples of what I'm using:
    XML to validate:
    <centres>
    <add>
    <centre>
    <centreName>Name 1</centreName>
    <centreRef>45678</centreRef>
    </centre>
    </add>
    </centres>
    Simple 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="centres" type="centresType"/>
    <xs:complexType name="addType">
    <xs:sequence>
    <xs:element type="xs:string" name="centreName"/>
    <xs:element type="xs:short" name="centreRef"/>
    </xs:sequence>
    </xs:complexType>
    <xs:complexType name="centresType">
    <xs:sequence>
    <xs:element type="addType" name="add" maxOccurs="3" minOccurs="0"/>
    </xs:sequence>
    </xs:complexType>
    </xs:schema>
    Complicated XSD:
    <?xml version="1.0" encoding="utf-8" ?>
    <!--Created with Liquid XML Studio - 30 Day Trial Edition 7.1.6.1440 (http://www.liquid-technologies.com)-->
    <xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
    <xs:element name="centres">
    <xs:complexType>
    <xs:sequence>
    <xs:element name="remove">
    <xs:complexType>
    <xs:sequence>
    <xs:element minOccurs="0" maxOccurs="1000" name="centreRef">
    <xs:simpleType>
    <xs:restriction base="xs:string">
    <xs:minLength value="1" />
    <xs:maxLength value="50" />
    </xs:restriction>
    </xs:simpleType>
    </xs:element>
    </xs:sequence>
    </xs:complexType>
    </xs:element>
    <xs:element name="add">
    <xs:complexType>
    <xs:sequence>
    <xs:element minOccurs="0" maxOccurs="1000" name="centre">
    <xs:complexType>
    <xs:sequence>
    <xs:element name="centreName">
    <xs:simpleType>
    <xs:restriction base="xs:string">
    <xs:minLength value="1" />
    <xs:maxLength value="100" />
    </xs:restriction>
    </xs:simpleType>
    </xs:element>
    <xs:element name="centreRef">
    <xs:simpleType>
    <xs:restriction base="xs:string">
    <xs:minLength value="1" />
    <xs:maxLength value="50" />
    </xs:restriction>
    </xs:simpleType>
    </xs:element>
    <xs:element minOccurs="0" maxOccurs="1" name="qualifications">
    <xs:complexType>
    <xs:sequence>
    <xs:element minOccurs="0" maxOccurs="1000" name="qualRef">
    <xs:simpleType>
    <xs:restriction base="xs:string">
    <xs:minLength value="1" />
    <xs:maxLength value="100" />
    </xs:restriction>
    </xs:simpleType>
    </xs:element>
    </xs:sequence>
    </xs:complexType>
    </xs:element>
    </xs:sequence>
    </xs:complexType>
    </xs:element>
    </xs:sequence>
    </xs:complexType>
    </xs:element>
    <xs:element name="modifyQualAssociations">
    <xs:complexType>
    <xs:sequence>
    <xs:element name="remove">
    <xs:complexType>
    <xs:sequence>
    <xs:element minOccurs="0" maxOccurs="1000" name="r">
    <xs:complexType>
    <xs:attribute name="centreRef" use="required">
    <xs:simpleType>
    <xs:restriction base="xs:string">
    <xs:minLength value="1" />
    <xs:maxLength value="50" />
    </xs:restriction>
    </xs:simpleType>
    </xs:attribute>
    <xs:attribute name="qualRef" use="required">
    <xs:simpleType>
    <xs:restriction base="xs:string">
    <xs:minLength value="1" />
    <xs:maxLength value="100" />
    </xs:restriction>
    </xs:simpleType>
    </xs:attribute>
    </xs:complexType>
    </xs:element>
    </xs:sequence>
    </xs:complexType>
    </xs:element>
    <xs:element name="add">
    <xs:complexType>
    <xs:sequence>
    <xs:element minOccurs="0" maxOccurs="1000" name="a">
    <xs:complexType>
    <xs:attribute name="centreRef" use="required">
    <xs:simpleType>
    <xs:restriction base="xs:string">
    <xs:minLength value="1" />
    <xs:maxLength value="50" />
    </xs:restriction>
    </xs:simpleType>
    </xs:attribute>
    <xs:attribute name="qualRef" use="required">
    <xs:simpleType>
    <xs:restriction base="xs:string">
    <xs:minLength value="1" />
    <xs:maxLength value="100" />
    </xs:restriction>
    </xs:simpleType>
    </xs:attribute>
    </xs:complexType>
    </xs:element>
    </xs:sequence>
    </xs:complexType>
    </xs:element>
    </xs:sequence>
    </xs:complexType>
    </xs:element>
    </xs:sequence>
    </xs:complexType>
    </xs:element>
    </xs:schema>

    Steps to validate XML data against a schema in Oracle:
    1. Register your XSD in the database.
    begin
    dbms_xmlschema.registerschema(
    SchemaUrl,
    SchemaDoc,
    local => TRUE/FALSE);
    end;
    2. For validating your XML document against your registered schema, here is a sample pl/sql block.
    declare
    v_xml xmltype;
    begin
    v_xml := your_xml_document;
    v_xml.schemaValidate();
    end;
    Hope this helps :)

  • Using "XML Document from XML Schema" in JDeveloper

    Hi Experts,
    I have a requirement to generate XML Document from XML Schema.
    For this I have used "XML Document from XML Schema" feature in JDeveloper. It is found in File->New->General->XML Document form XML Schema.
    I have registered a schema with jdev and got an XML document output for that successfully.
    Now, I want to implement this feature in my code for generating XML documents when XSD files are provided.
    Can any one please provide me with pointers to do that? I am sure there should be some libraries which can implement this feature.
    Thanks,
    Dilbagh

    Create an XML document from a Schema with the Oracle SchemaClassGenerator.
    import oracle.xml.classgen.SchemaClassGenerator;
    XMLSchema schema=new XMLSchema();
    XSDBuilder builder = new XSDBuilder();
    URL    url =  new URL(schemaUrl);     
    schema = (XMLSchema)builder.build(url);
    SchemaClassGenerator generator = new SchemaClassGenerator();
    Generate the Java classes from the example XML Schema.
    generator.generate(schema);With the java classes construct an XML document.

  • Help In XML schema using  oracle 10g

    i want to give seminar in XML schema using oracle 10g. n i m very new in this topic. so help me out which topic i include & any document regarding this

    XML Schema has various aspects.
    1. Creating an XML Schema, which may be done in JDeveloper.
    2. Initializing an XML document from an XML Schema, which may also be done in JDeveloper.
    For creating and initializing an XML Schema please refer
    http://www.regdeveloper.co.uk/2007/10/01/build_xml_schema_jdeveloper/
    3. Validating an XML document with an XML Schema.
    http://www.oracle.com/technology/pub/articles/vohra_xmlschema.html

Maybe you are looking for

  • IOS 8.1+ Performance Issue

    Hello, I encountered a serious performance bug in Adobe Air iOS application on devices running iOS 8.1 or later. Approximately in 1-2 minutes fps drops to 7 or lower without interacting with the app. This is very noticeable in the app. The app looks

  • How can I delete flagged emails that are not visible in my account boxes?

    Currently I show 43 flagged emails but not in any of my accounts is there a flag.  I am not sure if I deleted them early in learning to use my iphone 4s or what.  Certainly I had flagged email messages in the past.  Any suggestions?  I have tired goi

  • Tracks appearing in a random order

    OK, I'm a massive fan of a band called Feeder, and I've put all of their B-sides onto my computer. Now, I've numbered the tracks to relate to the dates they were released (1-58) and put them in an album entitled "B sides", but when I sort by "artist"

  • I downloaded adobe reader but cant open pdf files

    I downloaded adobe reader, but when i try to open a pdf all my screen shows is a black screen.  the odobe icon shows up on the bottom of my screen along with the other icons like launchpad, safari, etc.  what am i doing wrong?

  • Publish app that uses XML file.

    Hi, I want to create an App which uses XML file as a data source. I want that XML file is online file on my server downloaded in first use, and looking for changes every time user want to do this, so i have a legal question if apple can release my ap