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

Similar Messages

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

  • Unknown xml documents in all documents in finder

    Hello,
    Please could anyone help,  I have been looking finder at all documents and there are 100's of XML documents shown with lots of letters and numbers below.   When I try to open them they don't make sense, I have tried to delete them but they keep coming back, does anyone know why or how there are appearing?
    Also why do my photos keep doubling up?
    Thank you
    Sue

    Those are essential system and application files. Why are you even looking at all docs?
    Deleting files you don't understand is a quick way to turn your computer into an expensive brick.
    Now what's the problem with the photos? More detail is needed to determine what's happening.

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

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

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

  • Open XML document with proper layout

    Hi,
    I created my own XML form and I have problem when accessing the document within "KM Content".
    Indeed, when I click on the XML file generated by the XML Form it doesn't render it with the "Show" form but rather displays it as an usual XML document (with all its tags).
    Hint:
    I linked my iView to a custom CM repository. But, if I link my iView containing the XML Form to the out-of-the-box CM repository "/documents", it works fine.
    What should I do to make this work?
    Thanks in advance,
    Eric

    Hi Eric,
    in the Configuration under 'System Administration' -> 'System Configuration' -> 'Knowledge Management' -> 'Content Management' -> 'Repository Filters' you can find a filter named 'xmlforms_filter'. Some repositories are registered for this filter (in the standard e.g. documents). You should add your repositoriy here. After that the files in your repository should use the Show-form when being displayed.
    Hope this helps
    Karin

  • Error: No valid XML document received*_

    Hi All,
    We are connecting our CCMS system to NetWeaver J2EE engine on which E-Sourcing is running.
    For this we registered java component and hosts in cen.
    But we are getting error as : No valid XML document received
    Please can anyone tell me how to overcome this error.
    Thank you .
    Regards
    Mahesh

    Hi,
    Please re-read the answer from Marc carefully.  He was in the exact same situation as yours: 
    - Monitored system: NW CE 7.1
    - CEN: NW 7.01 (same as NW 7.0 EhP1)
    The link you posted is for CEN with NW 7.3 and monitored systems from NW 7.02 (and up).  Read the paragraph below the Caution sign:
    If you want to centrally monitor any system with a central monitoring system with release SAP NetWeaver 7.0, this procedure is not applicable. In this case, follow the procedure described in the newest Monitoring Setup Guide for SAP NetWeaver 7.0 instead. You can obtain the Monitoring Setup Guide at the Internet address service.sap.com/operationsnw70 in the Monitoring area.
    You should look for (and follow) the right Monitoring Setup Guide as mentioned.
    Regards,
    Dao
    Edited by: Dao Ha on Sep 19, 2011 10:38 AM

  • No valid XML document received

    Hi All,
    We are connecting our CCMS system to NetWeaver J2EE engine on which E-Sourcing is running.
    For this we registered java component and hosts in cen.
    But we are getting error as : No valid XML document received
    Please can anyone tell me how to overcome this error.
    Thank you .
    Regards
    Mahesh

    Hi,
    Please re-read the answer from Marc carefully.  He was in the exact same situation as yours: 
    - Monitored system: NW CE 7.1
    - CEN: NW 7.01 (same as NW 7.0 EhP1)
    The link you posted is for CEN with NW 7.3 and monitored systems from NW 7.02 (and up).  Read the paragraph below the Caution sign:
    If you want to centrally monitor any system with a central monitoring system with release SAP NetWeaver 7.0, this procedure is not applicable. In this case, follow the procedure described in the newest Monitoring Setup Guide for SAP NetWeaver 7.0 instead. You can obtain the Monitoring Setup Guide at the Internet address service.sap.com/operationsnw70 in the Monitoring area.
    You should look for (and follow) the right Monitoring Setup Guide as mentioned.
    Regards,
    Dao
    Edited by: Dao Ha on Sep 19, 2011 10:38 AM

  • Validating xml document in java

    Trying to do subject.
    I'm trying to use xsd from file(schemasource = 1) and from clob (schemasource = 0). I have two xsd schemas common_types.xsd and migom.xsd. second includes first. The problem is that when I'm using common_types schema from file I get error
    ORA-29532: Java call terminated by uncaught Java exception: oracle.xml.parser.v2.XMLParseException: An internal error condition occurred.
    and when I validate xml against only first schema has being read from clob I get success, but when I add second xsd, i get the same error, which says nothing at all.
    create or replace and compile java source named XmlTools AS
    import javax.xml.parsers.ParserConfigurationException;
    import javax.xml.parsers.SAXParser;
    import javax.xml.parsers.SAXParserFactory;
    import org.xml.sax.XMLReader;
    import org.xml.sax.InputSource;
    import oracle.sql.CLOB;
    import java.io.IOException;
    import org.xml.sax.SAXException;
    import java.sql.SQLException;
    import java.lang.IllegalArgumentException;
    import oracle.xml.parser.v2.XMLParseException;
    import javax.xml.parsers.ParserConfigurationException;
    import java.io.*;
    public class XmlValidator
    static final String JAXP_SCHEMA_LANGUAGE = "http://java.sun.com/xml/jaxp/properties/schemaLanguage";
    static final String W3C_XML_SCHEMA = "http://www.w3.org/2001/XMLSchema";
    static final String JAXP_SCHEMA_SOURCE = "http://java.sun.com/xml/jaxp/properties/schemaSource";
    public static void ValidateDocument(int schemasource, oracle.sql.CLOB schemadoc, oracle.sql.CLOB schemadoc1, oracle.sql.CLOB xmldoc) throws SAXException, IOException, SQLException, ParserConfigurationException, XMLParseException, IllegalArgumentException {
    try
    File myfile = new File(".//XML//common_types.xsd");
    if (myfile.exists())
    Serv.log("ValidateDocument", "file size" + Long.toString(myfile.length()));
    /*else
    Serv.log("ValidateDocument", "file doesn't exists" );
    Serv.log("ValidateDocument", "1" );
    SAXParserFactory factory = SAXParserFactory.newInstance();
    factory.setValidating(true);
    factory.setNamespaceAware(true);
    Serv.log("ValidateDocument", "2" );
    SAXParser saxParser = factory.newSAXParser();
    saxParser.setProperty(JAXP_SCHEMA_LANGUAGE, W3C_XML_SCHEMA);
    if (schemasource == 0)
    InputSource schemaIs = new InputSource(schemadoc.getCharacterStream());
    InputSource schemaIs1 = new InputSource(schemadoc1.getCharacterStream());
    InputSource[] schemas = {schemaIs, schemaIs1};
    //saxParser.setProperty(JAXP_SCHEMA_SOURCE, schemaIs);
    saxParser.setProperty(JAXP_SCHEMA_SOURCE, schemas);
    else
    saxParser.setProperty(JAXP_SCHEMA_SOURCE, ".//XML//common_types.xsd");
    XMLReader reader = saxParser.getXMLReader();
    //Получаем входной XML документ
    InputSource documentIs = new InputSource(xmldoc.getCharacterStream());
    Serv.log("ValidateDocument", "3" );
    //Запуск разбора
    reader.parse(documentIs);
    Serv.log("ValidateDocument", "4" );
    documentIs = null;
    /*catch (SAXException e)
    Serv.log("ValidateDocument", "SAXException" );
    Serv.log("ValidateDocument", "document is not valid because ");
    Serv.log("ValidateDocument", e.getMessage());
    throw(e);
    catch (ParserConfigurationException e)
    Serv.log("ValidateDocument", "ParserConfigurationException" );
    throw(e);
    catch (IOException e)
    Serv.log("ValidateDocument", "IOException" );
    throw(e);
    catch (XMLParseException e)
    Serv.log("ValidateDocument", "XMLParseException" );
    Serv.log("ValidateDocument", e.getMessage());
    StackTraceElement[] stack = e.getStackTrace();
    for (int i = 0; i < stack.length; i++)
    Serv.log("stacktrace element no " + Integer.toString(i), "toString: " + stack.toString());
    Serv.log("stacktrace element no " + Integer.toString(i), "file name: " + stack[i].getFileName() + ", class name: " + stack[i].getClassName() + ", method name: " + stack[i].getMethodName() + ", line : " + stack[i].getLineNumber());
    throw(e);
    catch (IllegalArgumentException e)
    Serv.log("ValidateDocument", "IllegalArgumentException" );
    Serv.log("ValidateDocument", e.getMessage());
    throw(e);
    additional information got from java stacktrace:
    file name: XMLError.java, class name: oracle.xml.parser.v2.XMLError, method name: flushErrors1, line : 320 file name: NonValidatingParser.java, class name: oracle.xml.parser.v2.NonValidatingParser, method name: parseDocument, line : 300 file name: XMLParser.java, class name: oracle.xml.parser.v2.XMLParser, method name: parse, line : 200 file name: XMLTOOLS, class name: XmlValidator, method name: ValidateDocument, line : 86
    my oracle version is Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Prod But my aim is to make it work on all versions starting from 9

    I found another examples of xml document validation in Java, but it seems to me that ORACLE's JVM doesn't include such class as SchemaFactory and class SAXParserFactory doesn't have method setSchema. Is it possible to update JVM installed in Oracle?
    SAXParserFactory factory = SAXParserFactory.newInstance();
    factory.setValidating(false);
    factory.setNamespaceAware(true);
    SchemaFactory schemaFactory =
    SchemaFactory.newInstance("http://www.w3.org/2001/XMLSchema");
    factory.setSchema(schemaFactory.newSchema(
    new Source[] {new StreamSource("contacts.xsd")}));
    SAXParser parser = factory.newSAXParser();
    XMLReader reader = parser.getXMLReader();
    reader.setErrorHandler(new SimpleErrorHandler());
    reader.parse(new InputSource("document.xml"));

Maybe you are looking for

  • Ipod nano black screen and isn't recognized on itunes

    Ipod nano 7th gen was working fine then the music started lagging and after about 30 seconds it just stopped working. I now have a black screen and it wont turn on. It is not being recognizedin itunes. What do I need to do to fix this issue. Any and

  • Monitor color correction

    no matter how i try to calibrate my monitor it seems off. different each time. the color correction utility isn't doing it for me. so i'm using an acer al2416w. i don't know if that matters at all. but what are some good products to do some real colo

  • Down Payment Request not being listed on F110

    Hi Guys I have completed down payment config for Sp GL indicator A and F. I have set up the recon accounts and allocated the required SP GL indicator to the paying company code. I have posted a down payment request. The open item credit is lying agai

  • How to move the screen (image) when using a tool?

    I know there is a shortcut and I forgot it, I am using the magnetic lasso tool and going through a detailed selection when I need to move the screen image because it is a lot bigger than what I can see. I know there is some keys to press for the hand

  • Global database links

    I am using global database links with Oracle Names. I have about a hundred databases ranging from 7.3.4 to soon to be 9i. Will OID support global database links in my environment? Is there any documentation dealing with global database links & OID. T