How to validate xml file with XSD schema ??  in JDK1.4.2

How to validate xml file with XSD schema ?? in JDK1.4.2
i dont want to use new Xerec Jar ...
Suggest option ...

Please do not double-post. http://forum.java.sun.com/thread.jspa?threadID=5134447&tstart=0
Then use Stax (Woodstock) or Saxon.
- Saish

Similar Messages

  • How to validate an XML file with XSD Schema on JDK 1.4

    Hi
    I'm looking for samples how to validate xml files with xsd schema using jsdk 1.4
    Thank you.

    This is how.
    import javax.xml.parsers.DocumentBuilder;
    import javax.xml.parsers.DocumentBuilderFactory;
    import javax.xml.transform.dom.DOMResult;
    import javax.xml.transform.dom.DOMSource;
    import javax.xml.validation.Schema;
    import javax.xml.validation.SchemaFactory;
    import javax.xml.validation.Validator;
    DocumentBuilderFactory dbfac = DocumentBuilderFactory.newInstance();
    dbfac.setNamespaceAware(true);
    SchemaFactory factory1 = SchemaFactory
                        .newInstance("http://www.w3.org/2001/XMLSchema");
    Schema schema = factory1.newSchema(new File("person.xsd"));
    dbfac.setSchema(schema);
    DocumentBuilder dbparser1 = dbfac.newDocumentBuilder();
    Document doc1 = dbparser1.parse(new File("person.xml"));
    Validator validator1 = schema.newValidator();
    DOMSource dm1 = new DOMSource(doc1);
    DOMResult domresult1 = new DOMResult();
    validator1.validate(dm1, domresult1);

  • Binding Xml file with Xsd Schema

    Hello
    everybody there.
    I am trying to make an application where word files are converted into xml.
    For that i have used org.exolab.castor and org.apache.poi.hwpf.
    Now the problem is that i was able to generate the xml file from word, but when i am binding it with XMLSchema.xsd following error is coming.
    java.lang.IllegalArgumentException: getSimpleType: the simple type 'formChoice' is not a built-in type as defined in XML Schema specification.
         at org.exolab.castor.xml.schema.Schema.getSimpleType(Schema.java:1289)
         at org.exolab.castor.xml.schema.Schema.addSimpleType(Schema.java:583)
         at org.exolab.castor.xml.schema.reader.SchemaUnmarshaller.endElement(SchemaUnmarshaller.java:643)
         at org.exolab.castor.xml.schema.reader.Sax2ComponentReader.endElement(Sax2ComponentReader.java:198)
         at org.apache.xerces.parsers.SAXParser.endElement(SAXParser.java:1392)
         at org.apache.xerces.validators.common.XMLValidator.callEndElement(XMLValidator.java:1550)
         at org.apache.xerces.framework.XMLDocumentScanner$ContentDispatcher.dispatch(XMLDocumentScanner.java:1149)
         at org.apache.xerces.framework.XMLDocumentScanner.parseSome(XMLDocumentScanner.java:381)
         at org.apache.xerces.framework.XMLParser.parse(XMLParser.java:1098)
         at org.exolab.castor.builder.SourceGenerator.generateSource(SourceGenerator.java:430)
         at org.exolab.castor.builder.SourceGenerator.generateSource(SourceGenerator.java:485)
         at TempHwpf.<init>(TempHwpf.java:35)
         at TempHwpf.main(TempHwpf.java:44)the code for binding my xml file with xsd schema is as under:-
    SourceGenerator sourcegen = new SourceGenerator();
    sourcegen.getVersion();
    System.out.println(sourcegen.getVersion());
    sourcegen.generateSource("XMLSchema.xsd","packagename");I have checked XMLSchema.xsd file, in that formChoice is already defined, than also error is coming.
    can anyone help me out. first i thought that XMLSchema.xsd which i have is not proper, but i downloaded it again from w3c.org,
    than also same error is shown.
    please help me out.
    waiting for reply.
    milind

    Please do not double-post. http://forum.java.sun.com/thread.jspa?threadID=5134447&tstart=0
    Then use Stax (Woodstock) or Saxon.
    - Saish

  • How to Map XML data with XSD Schema in JAXB

    Hello,
    I am very much new to JAXB.
    I am in need of someone help to go further in my dev.
    I am having an XSD and i could able to do marshall and unmarshall using JAXB.
    My problem is...
    Consider followings are my Schema...
    - <person id="general" help="USER.DOM.HELP.GENERAL" label="USER.DOM.LABEL.GENERAL" access="READWRITE">
    <attribute id="Name" mandatory="true" type="STRING" access="READONLY" widget="NONE" />
    <attribute id="login" label="USER.LABEL.LOGIN" help="USER.HELP.LOGIN" regexp="[A-a]" type="STRING" summary="true" access="WCREATE_RUPDATE" widget="TEXTFIELD" />
    <attribute id="firstname" summary="true" label="USER.LABEL.FIRSTNAME" help="USER.HELP.FIRSTNAME" type="STRING" regexp="[A-a]" access="READWRITE" widget="TEXTFIELD" />
    In this example a person contains set of attributes... some are mandatory(Name)...
    In my application i will unmarshall the the schema file and show in GUI as a set of attributes when the operator want to create a person. And its very well working.
    Now say for example, i am requesting my server to show all the created persons and its showing. when i click on the particular person the GUI will place the request to the server to get the corresponding date for the selected person.
    But the response contains only the mandatory attribute.. i mean Name.... this may be because of the way my server working. So now i want to show the operator all the set of attributes for that person with the Name.
    I mean i need to merge the schema with me resultant data and show it in the GUI.
    My result is in the form of xml stream. And i will convert my schema also in the form of XML...
    Now i need to merge both of this XMl and need to present in the GUI...
    Any help please...
    Thank You!!!

    Still i am not getting any reply :(

  • Catch all error information while validating xml content with xsd schema

    Hi experts,
    I created a java mapping to validating the input xml content with xsd schema (schema validation). What I want is to catch all error message to the xml not just the first error. I used SAXParser in sapxmltoolkit.jar to do the schema validation. The below is a part of my java mapping.
    XMLReader parser = XMLReaderFactory.createXMLReader("com.sap.engine.lib.xml.parser.SAXParser");
    parser.setFeature( "http://xml.org/sax/features/validation" ,  true);
    parser.setFeature( "http://apache.org/xml/features/validation/schema" , true);
    parser.setProperty("http://java.sun.com/xml/jaxp/properties/schemaLanguage", "http://www.w3.org/2001/XMLSchema");          parser.setProperty("http://java.sun.com/xml/jaxp/properties/schemaSource",this.getClass().getClassLoader().getResourceAsStream(schema)); // schema is my schema name
    parser.setErrorHandler(new ParseErrorHandler()); // ParseErrorHandler is my own ErrorHandler which extends DefaultHandler
    parser.parse(new InputSource(new ByteArrayInputStream(sinput.getBytes())));
    // In error handler, I comment all code so as not to throw any exception
    public class ParseErrorHandler extends DefaultHandler
         public void error(SAXParseException e) throws SAXException
              // sSystem.out.println("Error" + e.getMessage());
              // throw e;
         public void fatalError(SAXParseException e)
              // throw e;
              // System.out.println("SAP Fatal Error" + e.getMessage());
    Unfortunately the program always stopped while catching the first error. Check the below log.
    com.sap.engine.lib.xml.parser.NestedSAXParserException: Fatal Error: com.sap.engine.lib.xml.parser.ParserException:
    ERRORS :
    cvc-simple-type : information item '/:ShipNotice[1]/:Header[1]/:To[1]/:PartnerInformation[1]/:AddressInformation[1]/:CityName[1]' is not valid, because it's value does not satisfy the constraints of facet 'minLength' with value '1'.
    cvc-data : information item '/:ShipNotice[1]/:Header[1]/:To[1]/:PartnerInformation[1]/:AddressInformation[1]/:CityName[1]' is is not valid with respoct to the corresponding simple type definition.
    cvc-element : element information item '/:ShipNotice[1]/:Header[1]/:To[1]/:PartnerInformation[1]/:AddressInformation[1]/:CityName[1]' is associated with invalid data.
    cvc-element : element information item '/:ShipNotice[1]/:Header[1]/:To[1]/:PartnerInformation[1]/:AddressInformation[1]' is not valid with respect to it's complex type definition..
    cvc-element : element information item '/:ShipNotice[1]/:Header[1]/:To[1]/:PartnerInformation[1]' is not valid with respect to it's complex type definition..
    cvc-element : element information item '/:ShipNotice[1]/:Header[1]/:To[1]' is not valid with respect to it's complex type definition..
    cvc-element : element information item '/:ShipNotice[1]/:Header[1]' is not valid with respect to it's complex type definition..
    cvc-element : element information item '/:ShipNotice[1]' is not valid with respect to it's complex type definition..
    -> com.sap.engine.lib.xml.parser.ParserException:
    I tried using Xerces and JAXP to do validation, the same error happened. I have no idea on this. Does xi has its own error handler logic? Is there any body can make me get out of this?
    Thanks.

    <h6>Hi experts,
    <h6>
    <h6>I created a java mapping to validating the input xml content with xsd schema (schema validation). What I want is to catch all <h6>error message to the xml not just the first error. I used SAXParser in sapxmltoolkit.jar to do the schema validation. The below <h6>is a part of my java mapping.
    <h6>XMLReader parser = XMLReaderFactory.createXMLReader("com.sap.engine.lib.xml.parser.SAXParser");
    <h6>parser.setFeature( "http://xml.org/sax/features/validation" ,  true);
    <h6>parser.setFeature( "http://apache.org/xml/features/validation/schema" , true);
    <h6>parser.setProperty("http://java.sun.com/xml/jaxp/properties/schemaLanguage", "http://www.w3.org/2001/XMLSchema");          <h6>parser.setProperty("http://java.sun.com/xml/jaxp/properties/schemaSource",this.getClass().getClassLoader().getResourceAsStream(schema)); <h6>// schema is my schema name
    <h6>parser.setErrorHandler(new ParseErrorHandler()); // ParseErrorHandler is my own ErrorHandler which extends Default Handler
    <h6>parser.parse(new InputSource(new ByteArrayInputStream(sinput.getBytes())));
    <h6>
    <h6>// In error handler, I comment all code so as not to throw any exception
    <h6>public class ParseErrorHandler extends DefaultHandler
    <h6>{
    <h6>     public void error(SAXParseException e) throws SAXException
    <h6>     {
    <h6>          // sSystem.out.println("Error" + e.getMessage());
    <h6>          // throw e;
    <h6>     }
    <h6>
    <h6>     public void fatalError(SAXParseException e)
    <h6>     {
    <h6>          // throw e;
    <h6>          // System.out.println("SAP Fatal Error" + e.getMessage());
    <h6>
    <h6>     }
    <h6>
    <h6>}
    <h6>
    <h6>Unfortunately the program always stopped while catching the first error. Check the below log.
    <h6>
    <h6>com.sap.engine.lib.xml.parser.NestedSAXParserException: Fatal Error: com.sap.engine.lib.xml.parser.ParserException:
    <h6>ERRORS :
    <h6>cvc-simple-type : information item <h6>'/:ShipNotice[1]/:Header[1]/:To[1]/:PartnerInformation[1]/:AddressInformation[1]/:CityName[1]' <h6>is not valid, because it's value does not satisfy the constraints of facet 'minLength' with value '1'.
    <h6>cvc-data : information item <h6>'/:ShipNotice[1]/:Header[1]/:To[1]/:PartnerInformation[1]/:AddressInformation[1]/:CityName[1]' <h6>is is not valid with respoct to the corresponding simple type definition.
    <h6>cvc-element : element information item <h6>'/:ShipNotice[1]/:Header[1]/:To[1]/:PartnerInformation[1]/:AddressInformation[1]/:CityName[1]' <h6>is associated with invalid data.
    <h6>cvc-element : element information item <h6>'/:ShipNotice[1]/:Header[1]/:To[1]/:PartnerInformation[1]/:AddressInformation[1]' <h6>is not valid with respect to it's complex type definition..
    <h6>cvc-element : element information item <h6>'/:ShipNotice[1]/:Header[1]/:To[1]/:PartnerInformation[1]' <h6>is not valid with respect to it's complex type definition..
    <h6>cvc-element : element information item <h6>'/:ShipNotice[1]/:Header[1]/:To[1]' <h6>is not valid with respect to it's complex type definition..
    <h6>cvc-element : element information item <h6>'/:ShipNotice[1]/:Header[1]' <h6>is not valid with respect to it's complex type definition..
    <h6>cvc-element : element information item '/:ShipNotice[1]' is not valid with <h6>respect to it's complex type definition..
    <h6> -> com.sap.engine.lib.xml.parser.ParserException:
    <h6>
    <h6>
    <h6>I tried using Xerces and JAXP to do validation, the same error happened. I have no idea on this. Does xi has its own error <h6>handler logic? Is there any body can make me get out of this?
    <h6>Thanks.

  • How to convert XMl file to XSD file

    how to convert XMl file to XSD file ?
    i have a xml file format  it has to be converted to xsd file through ABAP .
    Regards
    Anbu B

    i got the answer....
    Regards
    Anbu B

  • How to validate xml againest to xsd

    HI,
    Xml contains multiple namespaces , I want validate xml againest to xsd. please any one can give help to me.
    thanks in adwance,

    see the sample code which fulfill ur need...
    /*--------------Validate.java------------------*/
    import java.io.File;
    import java.io.StringReader;
    import javax.xml.XMLConstants;
    import javax.xml.transform.stream.StreamSource;
    import javax.xml.validation.Schema;
    import javax.xml.validation.SchemaFactory;
    import javax.xml.validation.Validator;
    import org.xml.sax.SAXException;
    * This sample shows how new Validator APIs can be used to compile a standalone schema. This
    * feature is useful for those applications which are developing schema and wants to check
    * the validity of it as per the rules of schema language.
    *            Once an application has <code>Schema</code> object, it can be used to create
    * <code>Validator</code> which can be used to validate an instance document against the
    * schema or set of schemas this <code>Schema</code> object represents.
    public class Validate
        private static final boolean DEBUG = System.getProperty("debug") != null ? true : false;
        /** Parser the given schema and return in-memory representation of that
         *  schema. Compiling the schema is very simple, just pass the path of schema
         *  to <code>newSchema()</code> function and it will parse schema, check the
         *  validity of schema document as per the schema language, compute in-memory
         *  representation and return it as <code>Schema</code> object. Note that If
         *  schema imports/includes other schemas, those schemas will be parsed too.   
         * @param String path to schema file
         * @return Schema in-memory representation of schema.
        public static Schema compileSchema(String schema) throws SAXException
            //Get the SchemaFactory instance which understands W3C XML Schema language
            SchemaFactory sf = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);      
            if(DEBUG)
                System.out.println("schema factory instance obtained is " + sf);
            return sf.newSchema(new File(schema));
        }//compileSchema 
         * @param args the command line arguments
        public static void main(String[] args)
            try
                //parse schema first, see compileSchema function to see how
                //Schema object is obtained.
                Schema schema = compileSchema("NBO.XSD");
                //this "Schema" object is used to create "Validator" which
                //can be used to validate instance document against the schema
                //or set of schemas "Schema" object represents.
                Validator validator = schema.newValidator();
                //set ErrorHandle on this validator
                validator.setErrorHandler(new MyErrorHandler());
                //Validate this instance document against the instance document supplied
                validator.validate(new StreamSource("NBWO.XML"));           
            } catch(Exception ex)
                ex.printStackTrace();
                System.out.println("GET CAUSE:");
                ex.getCause().fillInStackTrace();
    /*---------MyErrorHandler()-----------*/
    * MyErrorHandler.java
    public class MyErrorHandler implements org.xml.sax.ErrorHandler
        /** Creates a new instance of MyErrorHandler */
        public MyErrorHandler()
        public void error(org.xml.sax.SAXParseException sAXParseException) throws org.xml.sax.SAXException
            System.out.println("ERROR: " + sAXParseException.toString());
            System.out.println("get error Msg : "+sAXParseException.getMessage());
        public void fatalError(org.xml.sax.SAXParseException sAXParseException) throws org.xml.sax.SAXException
            System.out.println("FATAL ERROR: " + sAXParseException.toString());
            System.out.println("get Error Message : "+sAXParseException.getMessage());
        public void warning(org.xml.sax.SAXParseException sAXParseException) throws org.xml.sax.SAXException
            System.out.println("WARNING: " + sAXParseException.toString());
    }With Cheers,
    Prasanna T

  • How to parse XML file with namesapce?

    Hi,
       I am trying to parse an xml file having namespace. But no data is returned.
    Sample Code:
    public class XMLFileLoader
    var xml:XML = new XML();
    var myXML:XML = new XML();
    var XML_URL:String = "file:///C:/Documents and Settings/Administrator/Desktop/MyData.xml";
    var myLoader:URLLoader = null;
    public function XMLFileLoader()
    var myXMLURL:URLRequest = new URLRequest(XML_URL);
    myLoader= new URLLoader(myXMLURL);
    myLoader.addEventListener(Event.COMPLETE,download);
    public function download(event:Event):void
    myXML = XML(myLoader.data);
    var ns:Namespace=myXML.namespace("xsi");
    for(var prop:String in myXML)
         trace(prop);
    //Alert.show(myXML..Parameters);
    //trace("Data loadedww."+myXML.toString());
    //Alert.show(myXML.DocumentInfo.attributes()+"test","Message");
    The XML Contains the following format.
    <Network xmlns="http://www.test.com/2005/test/omc/conf"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xsi:schemaLocation="http://www.test.com/2005/test/omc/conf/TestConfigurationEdition3proposal4.xsd">
        <TestDomain>
          <WAC>
            <!--Release Parameter  -->
            <Parameters ParameterName="ne_release" OutageType="None"
                        accessRight="CreateOnly" isMandatory="true"
                        Planned="false"
                        Reference="true" Working="true">
              <DataType>
                <StringType/>
              </DataType>
              <GUIInfo graphicalName="Release"
                       tabName="All"
                       description="Describes the release version of the managed object"/>
            </Parameters>
    </TestDomain>
    </Network>
    Any sample code how to parse this kind of xml file with namespaces...
    Regards,
    Purushotham

    i have exactly the same problem with KXml2, but using a j2me-polish netbeans project.
    i've tried to work around with similar ways like you, but none of them worked. now i've spent 3 days for solving this problem, i'm a bit disappointed :( what is wrong with setting the downloaded kxml2 jar path in libraries&resources?
    screenshot

  • How do you validate XML file against a Schema?

    Are there free applications that does that?

    Thanks, but how do you validata the Schema itself, which is an XML file.
    I know the schema DTD is online, but still I need some utility to do it
    Thanks

  • What's the best way to create XML file with a schema from a database table?

    Hi,
    I want to create an XML file from a database table (which has over 600 columns) using XML schema (.xsd file). I want to know the best way to do this.
    The output XML file is NOT a direct data dump from the DB table, there�re some logic around it, such as the XML file has some hierarchy with repeating tags.
    I have done this using JAXB by creating Java classes form XML schema, but I don�t want to map 600 DB columns to these Java classes manually, and loop through the record set to create repeating tags.
    I know there are few tools around now like MapForce (Altova), how do people do these now?
    Thanks,
    Chandi

    Can you use a schema when we compose XML doc from Database tables?
    Actually, I'm using SQL Server (sorry, wrong forum). But, I thought a Java tool would have a solution for me.

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

  • Problem validating XML file with external schema file

    Hi All
    I am having trouble at the moment trying to validate an xml file using an external xsd file that sits on my server. I have followed the basic option but at the moment to no avail. I am using a DOMParser and am setting all the features and properties correctly ... well I think I am anyway.....below is a fragment of the code
    DOMParser parser = new DOMParser ();
    // Setting the validation on for the parser.
    parser.setFeature ( "http://xml.org/sax/features/validation", true );
    parser.setFeature ( "http://apache.org/xml/features/validation/schema", true);
    parser.setProperty ( "http://apache.org/xml/properties/schema/externalnoNamespaceSchemaLocation", "c://testing.xsd" );
    parser.setErrorHandler ( this );
    I am getting an error telling me that the root element cannot be found.....see below
    org.xml.sax.SAXParseException: cvc-elt.1: Cannot find the declaration of element 'mainhome'.
    at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
    at org.apache.xerces.util.ErrorHandlerWrapper.error(Unknown Source)
    at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
    at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
    at org.apache.xerces.impl.xs.XMLSchemaValidator.handleStartElement(Unknown Source)
    at org.apache.xerces.impl.xs.XMLSchemaValidator.startElement(Unknown Source)
    at org.apache.xerces.impl.XMLNamespaceBinder.handleStartElement(Unknown Source)
    at org.apache.xerces.impl.XMLNamespaceBinder.startElement(Unknown Source)
    at org.apache.xerces.impl.dtd.XMLDTDValidator.startElement(Unknown Source)
    at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanStartElement(Unknown Source)
    at org.apache.xerces.impl.XMLDocumentScannerImpl$ContentDispatcher.scanRootElementHook(Unknown Source)
    at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
    at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
    at org.apache.xerces.parsers.DTDConfiguration.parse(Unknown Source)
    at org.apache.xerces.parsers.DTDConfiguration.parse(Unknown Source)
    at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
    at org.apache.xerces.parsers.DOMParser.parse(Unknown Source)
    at com.cibenix.aps.util.MenuXMLParser.process(MenuXMLParser.java:163)
    at com.cibenix.aps.actions.MenuAddAction.execute(MenuAddAction.java:80)
    at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:484)
    at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:274)
    at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
    at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:256)
    at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
    at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
    at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
    at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
    at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2417)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
    at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
    at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:171)
    at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172)
    at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
    at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
    at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
    at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
    at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:193)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:781)
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:549)
    at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:589)
    at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:666)
    Any help would be greatly appreciated
    thanks

    In the schema root element xs:schema add namespace declaration.
    <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
    In the XML document root element add xmlns:xsi and xsi:noNamespaceSchemaLocation attributes.
    <root_element xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="file://c:/testing.xsd">

  • How to validate xml file ?

    I try to validate my xml import file but I can't find proper validation and error message.
    the source where it originates is a system where also texts can be entered manually which are part of the xml file.
    I discoverd myself that & and ! are characters which are not allowed. but I'm looking for a way to check this before I process the xml file.
    I have this coding and I found smum_xml_parse but still the error is not clear about what is wrong ?
    try.
        CALL TRANSFORMATION ('ID')
        SOURCE XML it_xml_import
        RESULT order_header_in = st_sdhd1 order_conditions_in = ta_cond  order_partners = ta_parnr  order_text = ta_sdtext order_items_in = ta_sditm
    CATCH cx_xslt_exception INTO xslt_error.
    xslt_message = xslt_error->get_text( ).
        ASSIGN COMPONENT 'ERROR' OF STRUCTURE <l_line> TO <l_field>.
        <l_field> = xslt_message.
    data: gt_temp type STANDARD TABLE OF SMUM_XMLTB.
    itx_xml_import = it_xml_import.
    CALL FUNCTION 'SMUM_XML_PARSE'
      EXPORTING
        xml_input       = itx_xml_import
      tables
        xml_table       = gt_temp
        return          = ta_ret2
    ENDTRY.
    the xslt_message is also very unclear of what is exactly wrong with the file.
    are there any function which can give me more detailed information about the xml file and what is wrong with it ?
    Edited by: A. de Smidt on Feb 1, 2010 10:34 AM

    The ampersand is not allowed in XML CDATA, you must use the entity &amp;amp;

  • How to Create XML file with SAX parser instead of DOM parser

    HI ALL,
    I am in need of creating an XML file by SAX parser ONLY. As far as my knowledge goes, we can use DOM for such purpose(by using createElement, creatAttribute ...). Can anyone tell me, is there any way to create an XML file using SAX Parser only. I mean, I just want to know whether SAX provides any sort of api for Creatign an element, attribute etc. I know that SAX is for event based parsing. But my requirement is to create an XML file from using only SAX parser.
    Any help would be appreciated
    Thanx in advance
    Kaushik

    Hi,
    You must write a XMLWriter class yourself, and that Class extends DefaultHandle ....., the overwrite the startElement(url, localName, qName, attributeList), startDocument(), endElement().....and so on.
    in startElement write your own logic about how to create a new element and how to create a Attribute list
    in startDocument write your own logic about how to build a document and encodeType, dtd....
    By using:
    XMLWriter out = new XMLWriter()
    out.startDocument();
    Attribute attr1 = new Atribute();
    attr1.add("name", "value");
    out.startElement("","","Element1", attr1);
    Attribute attr2 = new Atribute();
    attr2.add("name", "value");
    out.startElement("","","Element2", attr2);
    out.endElement("","","Element2");
    out.endElement("","","Element1");
    out.endDocument();

  • How to generate xml file with multiple nodes using sqlserver as database in SSIS..

    Hi ,
    I have to generate the xml file using multiple nodes by using ssis and database is sqlserver.
    Can some one guide me on to perform this task using script task?
    sudha

    Why not use T-SQL for generating XML? You can use FOR XML for that
    http://visakhm.blogspot.in/2014/05/t-sql-tips-fun-with-for-xml-path.html
    http://visakhm.blogspot.in/2013/12/generating-nested-xml-structures-with.html
    Please Mark This As Answer if it solved your issue
    Please Vote This As Helpful if it helps to solve your issue
    Visakh
    My Wiki User Page
    My MSDN Page
    My Personal Blog
    My Facebook Page

Maybe you are looking for