XSL to validate xml structure using XSD

Hi,
Can you please provide me a sample xsl that validates input XML against the given schema?
I have been trying with the following, but I am getting an error in jdeveloper 11g.
XML-23003: (Error) XPath 2.0 feature schema-element/schema-attribute not supported
Process exited with exit code 1.
<?xml version="1.0" encoding="windows-1252" ?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:import-schema schema-location="po1.xsd"/>
<xsl:output method="xml" version="1.0" indent="yes"/>
<!-- Root template -->
<xsl:template match="/">
<xsl:if test="not(* instance of schema-element(authorising))">
<xsl:message terminate="yes">
Source document is not a validated Provisioning list
</xsl:message>
</xsl:if>
<xsl:apply-templates/>
</xsl:template>
</xsl:stylesheet>
Thanks
923344

Hi,
Can you please provide me a sample xsl that validates input XML against the given schema?
I have been trying with the following, but I am getting an error in jdeveloper 11g.
XML-23003: (Error) XPath 2.0 feature schema-element/schema-attribute not supported
Process exited with exit code 1.
<?xml version="1.0" encoding="windows-1252" ?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:import-schema schema-location="po1.xsd"/>
<xsl:output method="xml" version="1.0" indent="yes"/>
<!-- Root template -->
<xsl:template match="/">
<xsl:if test="not(* instance of schema-element(authorising))">
<xsl:message terminate="yes">
Source document is not a validated Provisioning list
</xsl:message>
</xsl:if>
<xsl:apply-templates/>
</xsl:template>
</xsl:stylesheet>
Thanks
923344

Similar Messages

  • 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

  • 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 read a file with data in Hierarchical Structure using XSD Schema

    Hi
    We have requirement in which we have to read a FIXED LENGTH file with FILE ADAPTER. File contains the data in hierarchical structure. Hierarchy in the file is identified by the first 3 characters of every line which could be any of these : 000,001,002,003 and 004. Rest files are followed after these. So structure is like:
    000 -- Header of File. Will come only once in file. Length of this line is 43 characters
    -- 001 -- Sub Header. Child for 000. Can repeat in file. Length of this line is 51 characters
    --- 002 -- Detail record. Child for 001. Can repeat multiple times in given 001. Length of this line is 43 characters 1353
    -- 003 -- Sub Footer record at same level of 001. Will always come once with 001 record. Child for 000. Length of this line is 48 characters
    004 -- Footer of file.At same level of 000. Will come only once in file. Length of this line is 48 characters
    Requirement is to create an XSD which should validate this Hierarchical Structure also i.e data should come in this hierarchy only else raise an error while parsing the file.
    Now while configuring the FILE ADAPTER to read this file we are using Native Schema UI to create the XSD to parse this structure using an example data file. But we are not able to create a valid XSD for this file which should validate the Hierarchy also on the file.
    Pls provide any pointers or solution for this.
    Link to download the file, file structure details and XSD that we have created:
    https://docs.google.com/file/d/0B9mCtbxc3m-oUmZuSWRlUTBIcUE/edit?usp=sharing
    Thanks
    Amit Rattan
    Edited by: user11207269 on May 28, 2013 10:16 PM
    Edited by: user11207269 on May 28, 2013 10:31 PM
    Edited by: user11207269 on May 28, 2013 10:33 PM

    Heloo.. Can anyone help me on this. I need to do Hierarchial read / validation while reading the file using File Adapter using Native XSD schema.

  • Validate XML file using nested XSD's

    Hi,
    I am currently trying to create a method that can validate a XML document based on a long series of nested XSD's.
    I am however not sure of how to implement this validation with the nested XSD's.
    Currently I have created the following function:
         public void validate(InputStream xmlDocument) {
              try {
                   SAXParserFactory spf = SAXParserFactory.newInstance();
                   spf.setNamespaceAware(true);
                   spf.setValidating(true);
                   SAXParser sp = spf.newSAXParser();
                   InputStream schema1 = this.getClass().getResourceAsStream("schema.xsd");
                   InputStream schema2 = this.getClass().getResourceAsStream("schema1.xsd");
                   Object[] schemas = {schema1,schema2};
                   final String JAXP_SCHEMA_LANGUAGE = "http://java.sun.com/xml/jaxp/properties/schemaLanguage";
                   final String W3C_XML_SCHEMA = "http://www.w3.org/2001/XMLSchema";
                   final String JAXP_SCHEMA_SOURCE = "http://java.sun.com/xml/jaxp/properties/schemaSource";
                   sp.setProperty(JAXP_SCHEMA_LANGUAGE, W3C_XML_SCHEMA);
                   sp.setProperty(JAXP_SCHEMA_SOURCE, schemas);
                   sp.parse(xmlDocument, new ParseErrorHandler());
              } catch (SAXException e) {
                   System.out.println(e.toString());
              } catch (ParserConfigurationException e) {
                   System.out.println(e.toString());
              } catch (IOException e) {
                   System.out.println(e.toString());
    The schemas that I reference are imported into the namespace of the class that contains the above method. schema.xsd contains a reference to schema1.xsd.
    The exception that I get is:
    com.sap.engine.lib.xml.parser.NestedSAXParserException: Generic Exception: -> com.sap.engine.lib.xml.util.NestedException: [location : null] ERROR : schema1.xsd (The system cannot find the file specified)
    This I dont understand since the schema1.xsd is located right along with schema.xsd which is found without trouble.
    Hope someone can clearify this issue for me, since I'm somewhat lost.
    Best regards,
    Daniel

    Hi,
    I am currently trying to create a method that can validate a XML document based on a long series of nested XSD's.
    I am however not sure of how to implement this validation with the nested XSD's.
    Currently I have created the following function:
         public void validate(InputStream xmlDocument) {
              try {
                   SAXParserFactory spf = SAXParserFactory.newInstance();
                   spf.setNamespaceAware(true);
                   spf.setValidating(true);
                   SAXParser sp = spf.newSAXParser();
                   InputStream schema1 = this.getClass().getResourceAsStream("schema.xsd");
                   InputStream schema2 = this.getClass().getResourceAsStream("schema1.xsd");
                   Object[] schemas = {schema1,schema2};
                   final String JAXP_SCHEMA_LANGUAGE = "http://java.sun.com/xml/jaxp/properties/schemaLanguage";
                   final String W3C_XML_SCHEMA = "http://www.w3.org/2001/XMLSchema";
                   final String JAXP_SCHEMA_SOURCE = "http://java.sun.com/xml/jaxp/properties/schemaSource";
                   sp.setProperty(JAXP_SCHEMA_LANGUAGE, W3C_XML_SCHEMA);
                   sp.setProperty(JAXP_SCHEMA_SOURCE, schemas);
                   sp.parse(xmlDocument, new ParseErrorHandler());
              } catch (SAXException e) {
                   System.out.println(e.toString());
              } catch (ParserConfigurationException e) {
                   System.out.println(e.toString());
              } catch (IOException e) {
                   System.out.println(e.toString());
    The schemas that I reference are imported into the namespace of the class that contains the above method. schema.xsd contains a reference to schema1.xsd.
    The exception that I get is:
    com.sap.engine.lib.xml.parser.NestedSAXParserException: Generic Exception: -> com.sap.engine.lib.xml.util.NestedException: [location : null] ERROR : schema1.xsd (The system cannot find the file specified)
    This I dont understand since the schema1.xsd is located right along with schema.xsd which is found without trouble.
    Hope someone can clearify this issue for me, since I'm somewhat lost.
    Best regards,
    Daniel

  • How to validate XML files using several XSD?

    hi friends i need java code for this application >?
    Plz. help me urgent............

    Use the parser property
    http://apache.org/xml/properties/schema/external-schemaLocation
    to specify more than one schemas.
    http://xerces.apache.org/xerces2-j/properties.html

  • DBMS to XML file using XSD for validarion rules

    Hi All,
    I am working on a migration project and my goal is to generate XML file (should also validate using XML Schema) from MySql and SQLServer database.
    Idea is to write a query and then visually map result fields to XSD file (for basic field validation) and produce XML file.
    Is there any example doing same using ODI???
    I really don't want to export tables (500+, 3M+ records) into Oracle database and then write java or pl/sql code to generate XML file.
    Any inputs highly appreciated.
    Thanx,
    Chirag Jha | Principal Consultant
    Phone: +1 561 244 5607 | Fax: +1 815 550 7245 | Mobile: +1 561 926 3308
    Oracle Oracle Communications Global Business Unit

    Hi,
    Any help on this subject?
    Thanx,
    Chirag

  • Validate xml fails using XInclude.

    I tried to use the XInclude syntax in a very simple way in order to make my xml more modular.
    Here the example :
    <?xml version='1.0' encoding='windows-1252'?>
    <frame name="pippo" xmlns:xi="http://www.w3.org/2001/XInclude" xmlns:xsd="http://www.w3.org/2001/XMLSchema-instance" xsd:schemaLocation="http://www.axioma.it/AXI Frames.xsd" xmlns="http://www.axioma.it/AXI">
    <vo name="prova">
    <xi:include href="Incluso.xml" parse="xml"/>
    </vo>
    </frame>
    The validate Xlm fails with this error
    Error(4,45): <Line 4, Column 45>: XML-24534: (Error) Element 'include' not expected.
    How can avoid this ?
    Did I forget something ?
    Tks
    Tullio

    I'm quite new and I don't know exactly the syntax You are speaking about.
    I just need to create an xml file, wich is validated by Frames.xsd, including in it some other xml fragments I need to reuse.
    In my code I named 2 xmlspaces, my own and xi wich refers to include specification and I thought it was enough in order to use XInclude specification, is it wrong ?
    How can I specify what I need ?
    Tks
    Tullio

  • How to read an xml database using xsd file in labview

    I have Labview 8.5. I have an xml file (Database) that contains data from sensors. The data doesnt conform to the LabView's xml schema we have our own schema for the data. is there a way to extract the  digitized waveform data from this xml file by using our own xsd file?
    Regards
    Shoaib

    I am attaching the xsd file here since I am not sure if by attaching the actual 3MB XML file i will be giving away any info that im not supposed to.Please rename the attachement to fmd.xsd
    All i'm looking for is to somehow get the data defined by the following
      <xs:complexType
    name="T_sample">
      <xs:attribute name="num" type="xs:int" use="required"
    />
      <xs:attribute name="value" type="xs:int"
    use="required" />
      <xs:attribute name="value_mv" type="xs:float"
    use="required" />
      </xs:complexType>
    Attachments:
    fmd.txt ‏24 KB

  • Creating a table structure using xsd file or excel?

    Hi,
    How to create a table structure of the xsd file or excel file generated from access 2000?
    Do you have any ideas or do you know any useful tools for this?

    Yes. This possible with ADF Faces RC, which provides an af:tree component. Have a look at the Fusion Order Demo, which uses the tree to implement a similar usecase to the one you describe.
    http://www.oracle.com/technology/products/jdev/samples/fod/index.html
    Regards,
    RiC

  • How to add a textline to an xml structure using xslt

    Hi,
    I am having a requirement where i need to add a textline to an xml.
    scenario: IDOC-File  and output format is an xml.
    Output should be like this:
    &&##AOC0MB000#AD15543390#BOIFCO#Z
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <messages>
         <batch>0800062844</batch>
         <message>
              <type>VPR</type>
              <action>A</action>
              </body>
         </message>
    </messages>
    The line that has been added to xml is the data that will be coming from IDOC. How can we append the textline to the xml using xslt.Will document() in xslt works for doing this?

    The required format in ur scenario is not an xml format, so u should not save the file in xml format. U may write an adapter module at receiver to achieve this.
    How can we append the textline to the xml using xslt
    This is not possible as the output of xsl transformation is an xml file.
    Regards,
    Prateek

  • HOW TO USE isSchemaValid() in oracle 9i to validate XML against XSD

    Hi
    I am trying to validate xml file against xsd in oracle 9i.The steps are as follows:
    *1.Created directory for xml and xsd file location:*
    CREATE or replace DIRECTORY XML_DATA AS 'D:\prod\sample xml and xsd;
    *2.Register the schema*
    DECLARE
    bf5 BFILE;
    BEGIN
    -- Register the schema
    dbms_lob.filecloseall;
    bf5 := BFILENAME('XML_DATA','xml1.xsd');
    DBMS_XMLSCHEMA.registerSchema('http://www.example.com/schemas/ipo.xsd',bf5,TRUE, TRUE, FALSE,TRUE,TRUE);
    -- dbms_lob.fileclose(bf5);
    END;
    *3.creatibg table to store xml files*
    CREATE TABLE po_tab2 (id NUMBER,xmlcol SYS.XMLType) ;
    *4.Inserting xml file into the table and validating that file with xml schema*
    declare
    aa clob:=' ';
    b varchar2(4000);
    c xmltype;
    begin
    dbms_lob.filecloseall;
    aa:= GETCLOBDOCUMENT('XML_DATA','example.XML','WE8MSWIN1252');
    INSERT INTO po_tab2 (ID, XMLCOL)
    VALUES
    (104,sys.XMLType.createXML(aa));
    commit;
    --c:=sys.xmltype.createXml(aa);
    c:=xmltype(aa);
    b:=VerifyXML(c,'http://www.example.com/schemas/ipo.xsd');
    dbms_output.put_line(b);
    end;
    _5.VerifyXML function is:_
    create or replace
    function VerifyXML( xml xmltype, xmlSchema varchar2 ) return varchar2 AUTHID DEFINER is
    xmlURL varchar2(4000);
    begin
    select
    s.qual_schema_url into xmlURL
    from user_xml_schemas s
    where s.schema_url = xmlSchema;
    if xml.isSchemaValid(xmlURL,'ManageRolloutRegionNotification') =1 then
    return( 'Valid. The supplied XML complies with XSD '||xmlURL );
    else
    -- return null;
    return(sqlcode|| 'Failed. The supplied XML does not comply with XSD '||xmlURL );
    end if;
    exception when others then
    return(sqlcode);
    end;
    _6.PROBLEM:_
    the problem is the function is always returning 'Failed ' status even though I am giving the correct file.. Is there any method to find the reason for failure. These codes are working fine oracle 11g. currently i am working in 9i version 9.2.0.1.0. I

    Oracle 9iR2 is not supported anymore.
    Oracle 9.2.0.8 is in sustained support.
    Oracle 9.2.0.1 is not supported at all.
    Upgrade to 11gR2.
    Sybrand Bakker
    Senior Oracle DBA

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

  • Special characters in XML structure when prepared using String

    Hi,
       I am preparing an XML structure using 'String'. I print the prepared XML structure in the server log. Issue is that I am seeing extra characters([[ and ]]) that I am not printing.
    Please let me know how to get rid of those.
    Code Excerpt
            String xmlHeader = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>";
            String lsb_xmlcon = xmlHeader;
            logger.info("ReqXMLString Process  1  --->" + lsb_xmlcon);
            lsb_xmlcon = lsb_xmlcon +("\n");
            logger.info("ReqXMLString Process  1.1  --->" + lsb_xmlcon);
            lsb_xmlcon = lsb_xmlcon +("<REQUEST>");
            lsb_xmlcon = lsb_xmlcon +("\n");
            logger.info("ReqXMLString Process  1.2  --->" + lsb_xmlcon);
    Log
    ReqXMLString Process  1  ---><?xml version="1.0" encoding="utf-8" ?>
    ReqXMLString Process  1.1  ---><?xml version="1.0" encoding="utf-8" ?>[[
    ReqXMLString Process  1.2  ---><?xml version="1.0" encoding="utf-8" ?>[[
    <REQUEST>
    Thanks,
    Message was edited by: 996913
    This issue is observed only while running the code in server, not from Jdev.
    When we append the additional tags without new line character, "\n", there are no extra characters being added. Also, in other case also. where we used "Marshaller" to prepare the XML, we have seen this issue.
    After we set the below property to false, we got rid of the extra characters.
                            jaxbMarshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, false);
    Apparently the insertion of new line when the code runs on server(Weblogic 10.3.6.0) is creating the issue.
    Please let me know if anyone has come across a similar scenario.
    Thanks,

    I am building this XML in a servlet so ,right, DOM does process XML (even though a valid HTML file can be loaded into a DOM object) but if you build XML using DOM then write the XML out using PrintWriter and Transformer objects this will cause the XML to print out in your browser. If you view source on this XML you will see that the DOM object has translated all special characters to there &xxxx; equivalent. For a example: when the string (I know "cool" java) gets loaded into a attribute using the DOM object then wrote back out it looks like (I know &xxx;cool&xxx; java) if you view the source in your browser. This is what it should do, but the DOM object is not change the � to the "&xxxxx;". This servlet is acting as a gateway between a Java API and a windows asp. The asp will call the servlet expecting to get XML back and load it directly into a DOM object. When the windows DOM object gets the xml that I am returning in this servlet is throws a exception "invalid character" because the � was not translated to &xxxx; like the other characters were. According to the book HTML 4 in 24 hours (and other references) the eacute; or #233; are how you say "�" in HTML or XML. How do you say it?

  • Generation of XML using XSD

    I Have to generate XML file using XSD. I have the xsd available with me ,i have the values of elements also,now i need create a xml file using the XSD or DTD, with the values i got from the database.
    Kindly help.

    Create an XML file from XSD file

Maybe you are looking for

  • Infotype 2011 - Load complete

    Hello people, I have a question about infotype  2011. I made a follow code: INFOTYPE: 2011 PROVIDE .... P2011 BETWEEN PN-BEGDA AND PN-ENDDA On screen parameter I put 21.06 until 20.07 in Other period , and same period in P.SelcPeriod. But the table p

  • Notes problem after Mavericks upgrade

    Notes will not sync after Mavericks upgrade, other apps - mail & contacts & calendar do sync

  • Activating C program on different folder

    Hi, I am trying to activate a C program from within my java program using Runtime.getRuntime().exec("program name") this C program is dealing with various files from it's directory - which is different from my my java's app directory. the C app seems

  • Adobe Captivate 4 Quiz Issues

    My Clear button will not clear the answer if the wrong answer is selected. Once a user selects an answer, it can't be changed. How do I fix this? The Continue button on the Quiz Results slide does not continue. How do I fix this?

  • Uninstall CS3 on Mac?

    How to uninstall PS3 on my mac prior to installing CS6?