WLI : how to validate XML / MFL instances against specifications.

Hi,
Does anybody know how a variable inside a workflow
containing XML or binary data can be validated against
an XSD or MFL?
Greetings,
Davy Toch

You can tell the parser where to look for external entities. The parser allows
you to set your entity resolver -->
Using JAXP --> documentBuilder.setEntityResolver(new MyEntityResolver());
Using Xerces DOMParser --> parser.setEntityResolver(new MyEntityResolver());
Your Entity Resolver implements: InputSource resolveEntity(String publicID, String
systemID). You can implement this method to find and return an InputSource loaded
with your xsd. So the parser will call this method -- and pass in the systemID
it is looking for. Based on that systemID, you can have the method look in the
appropriate location.
"Karthik V" <[email protected]> wrote:
Jared,
That is interesting... If you do not specify the location of the schema
in
your instance document, then how do you validate it. You said your app
will
lookup the schema location. Does this mean that you do 2 step parsing?
First you parse the document and get the schema name (Say MySchema.xsd),
next you identify the schema location and parse it once more for validation
against the schema.
I know it is slightly off topic. But I would be interesed in understanding
your idea.
Thanks.
/k
"Jared" <[email protected]> wrote in message
news:[email protected]...
I think you could attack this a few ways.
If you pass the XML to your BO, you could override your parser's entityresolver
-- and redirect the xsd lookup to the actual location of XSDs. I knowthat you
said you are keeping them in the WLI repository -- but do you loadthem
into the
WLI repository from the filesystem or something? That filesystem couldbe
where
you look for the xsd.
Also, you MIGHT be able to use the XML Registry -- which also can beused
to redirect
where your BO looks for the XSD.
When I reference my XSD or DTD, I make sure that it does not containa
protocol
(eg http://). We made a rule that we will all use the filename of
the
schema
(eg asdf.xsd). Then each app could look where they wanted for theschema.
I
know this introduces problems of version control -- but we didn't wantto
have
a single point of failure for all applications just because the DTDserver
may
be down.
"Davy Toch" <[email protected]> wrote:
Hi,
I also thought of using a Business Operation, but the problem is how
to
reference the
specification in the xml instance when the specification is located
in
the
WLI repository.
I thought of recuperating the needed specification in a String variable
and
passing that too
to the Business Operation. But this poses a problem forSAXParser/DOMParser,
since
you can't specify that the specification is actually available ina
String.
Regards,
Davy Toch
"Jared" <[email protected]> wrote in message
news:[email protected]...
I don't know about MFL, but you can validate an XML against an XSDby
calling a
java class (business operation) and letting that java class validate.
I know this probably insn't the most efficient way -- or the mostappropriate
way to do it -- but it should work.
"Davy Toch" <[email protected]> wrote:
Hi,
Does anybody know how a variable inside a workflow
containing XML or binary data can be validated against
an XSD or MFL?
Greetings,
Davy Toch

Similar Messages

  • How to validate XML against XSD and parse/save in one step using SAXParser?

    How to validate XML against XSD and parse/save in one step using SAXParser?
    I currently have an XML file and XSD. The XML file specifies the location of the XSD. In Java code I create a SAXParser with parameters indicating that it needs to validate the XML. However, SAXParser.parse does not validate the XML, but it does call my handler functions which save the elements/attributes in memory as it is read. On the other hand, XMLReader.parse does validate the XML against the XSD, but does not save the document in memory.
    My code can call XMLReader.parse to validate the XML followed by SAXParser.parse to save the XML document in memory. But this sound inefficient. Besides, while a valid document is being parsed by XMLReader, it can be changed to be invalid and saved, and XMLReader.parse would be looking at the original file and would think that the file is OK, and then SAXParser.parse would parse the document without errors.
    <Book xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="book.xsd" name="MyBook">
      <Chapter name="First Chapter"/>
      <Chapter name="Second Chapter">
        <Section number="1"/>
        <Section number="2"/>
      </Chapter>
    </Book>
    <?xml version="1.0" encoding="ISO-8859-1" ?>
    <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
    <xs:element name="Book">
    <xs:complexType>
      <xs:sequence>
       <xs:element name="Chapter" minOccurs="0" maxOccurs="unbounded">
        <xs:complexType>
         <xs:sequence>
          <xs:element name="Section" minOccurs="0" maxOccurs="unbounded">
           <xs:complexType>
            <xs:attribute name="xnumber"/>
          </xs:complexType>
          </xs:element>
         </xs:sequence>
         <xs:attribute name="name"/>
        </xs:complexType>
       </xs:element>
      </xs:sequence>
      <xs:attribute name="name"/>
    </xs:complexType>
    </xs:element>
    </xs:schema>
    public class SAXXMLParserTest
       public static void main(String[] args)
          try
             SAXParserFactory factory = SAXParserFactory.newInstance();
             factory.setNamespaceAware(true);
             factory.setValidating(true);
             SAXParser parser = factory.newSAXParser();
             parser.setProperty("http://java.sun.com/xml/jaxp/properties/schemaLanguage",
                                "http://www.w3.org/2001/XMLSchema");
             BookHandler handler = new BookHandler();
             XMLReader reader = parser.getXMLReader();
             reader.setErrorHandler(handler);
             parser.parse("xmltest.dat", handler); // does not throw validation error
             Book book = handler.getBook();
             System.out.println(book);
             reader.parse("xmltest.dat"); // throws validation error because of 'xnumber' in the XSD
    public class Book extends Element
       private String name;
       private List<Chapter> chapters = new ArrayList<Chapter>();
       public Book(String name)
          this.name = name;
       public void addChapter(Chapter chapter)
          chapters.add(chapter);
       public String toString()
          StringBuilder builder = new StringBuilder();
          builder.append("<Book name=\"").append(name).append("\">\n");
          for (Chapter chapter: chapters)
             builder.append(chapter.toString());
          builder.append("</Book>\n");
          return builder.toString();
       public static class BookHandler extends DefaultHandler
          private Stack<Element> root = null;
          private Book book = null;
          public void startDocument()
             root = new Stack<Element>();
          public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException
             if (qName.equals("Book"))
                String name = attributes.getValue("name");
                root.push(new Book(name));
             else if (qName.equals("Chapter"))
                String name = attributes.getValue("name");
                Chapter child = new Chapter(name);
                ((Book)root.peek()).addChapter(child);
                root.push(child);
             else if (qName.equals("Section"))
                Integer number = Integer.parseInt(attributes.getValue("number"));
                Section child = new Section(number);
                ((Chapter)root.peek()).addSection(child);
                root.push(child);
          public void endElement(String uri, String localName, String qName) throws SAXException
             Element finished = root.pop();
             if (root.size() == 0)
                book = (Book) finished;
          public Book getBook()
             return book;
          public void error(SAXParseException e)
             System.out.println(e.getMessage());
          public void fatalError(SAXParseException e)
             error(e);
          public void warning(SAXParseException e)
             error(e);
    public class Chapter extends Element
       public static class Section extends Element
          private Integer number;
          public Section(Integer number)
             this.number = number;
          public String toString()
             StringBuilder builder = new StringBuilder();
             builder.append("<Section number=\"").append(number).append("\"/>\n");
             return builder.toString();
       private String name;
       private List<Section> sections = null;
       public Chapter(String name)
          this.name = name;
       public void addSection(Section section)
          if (sections == null)
             sections = new ArrayList<Section>();
          sections.add(section);
       public String toString()
          StringBuilder builder = new StringBuilder();
          builder.append("<Chapter name=\"").append(name).append("\">\n");
          if (sections != null)
             for (Section section: sections)
                builder.append(section.toString());
          builder.append("</Chapter>\n");
          return builder.toString();
    }Edited by: sn72 on Oct 28, 2008 1:16 PM

    Have you looked at the XML DB FAQ thread (second post) in this forum? It has some examples for validating XML against schemas.

  • How to validate xml using xsd

    Hi All
    please tell me how to validate xml using xsd
    regards

    Try using this link:
    = http://www.google.nl/search?q=XML+validate+oracle for instance or
    = use the search button on this forum and / or
    = read the FAQ on this (XML DB FAQ
    Thanks Eddie et all, for educating me via http://awads.net/wp/2006/11/14/barts-punishment-for-asking-dumb-questions (don't mind the URL , the info there is really useful)
    The following link on this site is just brilliant: http://www.albinoblacksheep.com/flash/posting.php
    Grz
    Marco
    Message was edited by:
    mgralike

  • 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 using java_xml_pack-summer-02?

    In jaxp1.1, we validate the xml file in this way:
    c:\java -jar Validator.jar myBookStore.xml
    However, in java_xml_pack-summer-02, which is latest version of jaxp, the Validator.jar is not available. So, how to validate xml file?
    Pls help.

    develop your own validator... here is a quick and dirty one, which spits exceptions when error are met:
    import java.io.*;
    import javax.xml.parsers.*;
    import org.xml.sax.*;
    import org.xml.sax.helpers.DefaultHandler;
    public class Validator
      public static void main(String[] args) throws Exception {
        SAXParserFactory spf = SAXParserFactory.newInstance();
        spf.setValidating(true);
        spf.setNamespaceAware(true);
        SAXParser sp = spf.newSAXParser();
        sp.parse(new File(args[0]), new DefaultHandler());
    }

  • 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 validate XML at runtime and show the exact cause of validation failure .

    Hi
    How can I validate my generated XML at runtine against its schema ? I have used
    the validate() method and it does validate correctly against the schema but the
    problem is it just returns a boolean . I need to know the exact cause of failure
    (like for example The element X was supposed to contain Y,Z etc ). I need to capture
    the exact exception (like a Sax Parse exception details).
    How do i do that using XMLBeans ??
    - Bana

    Hi Bana,
    You could use the XmlOptions.setErrorListener(Collection) method to get the detailed error message by invoking validate(option).
    Kind Regards,
    Jennifer

  • How to validate XML Digital Signature with XML DB (o PL/SQL) in Oracle 11g

    Hi,
    Do you know if there is possibility to validate XML Digital Signature using XML DB (or PL/SQL) in Oracle 11g?
    Let say I have CLOB/XMLType containing Digitally Signed XML, and I want to validate, that thsi is proper signature. I also have public key of signer (I could store it in CLOB or file or Oracle wallet).
    Is it possible to do?
    If there is need to install additional component - then which one?
    Regards,
    Paweł

    Hi,
    this is what i got from someone...
    but the links he gave are not opening up...
    u have to place a picture there and have to load the digital signatures as Jpegs on to the server to OA top
    and have to refer them in the XML for dynamically get the signature on the reports
    when u select the properties of the picture placed in the XML template,
    there will be one tab with "URL"... in that u have to give the path for that jpegs
    Pls refer the following documents for enabling digital signature on pdf documents.
    http://iasdocs.us.oracle.com/iasdl/bi_ee/doc/bi.1013/e12187/T421739T481159.htm#5013638    (refer section 'Adding or Designating a Field for Digital Signature'
    http://iasdocs.us.oracle.com/iasdl/bi_ee/doc/bi.1013/e12188/T421739T475591.htm#5013688
    (Implementing a Digital Signature
    Is the BI Publisher installed on your instance of version 10.1.3.4 or higher?
    Pls procure a digital signature as soon as possible. The process can take time. OR we could use any certificate that you already might have OR generate a certificate using Oracle Certificate Authority for demo.

  • How to Validate XML against XSD through PL/SQL?

    Hi friends,
    I m new to this forum. This is my first query.
    In our project, we are trying to generate output XML using PL/SQL procedure. I have done that successfully. Now my problem is I have to validate this against our XSD. How will I do that? Can you provide me with a sample example.
    Thanks to all in advance.
    Regards,
    apk

    Have you looked at the XML DB FAQ thread (second post) in this forum? It has some examples for validating XML against schemas.

  • How to validate XML against Schema

    Hi,
    I am trying to validate the XML against the schema by using follywing code but i am never getting errors in parser it always passes the parser even though there are serious parsing problems. My code is as follows:
    SAXParserFactory spf = SAXParserFactory.newInstance();
    spf.setNamespaceAware(true);
    spf.setValidating(true);
    SAXParser sp = spf.newSAXParser();
    sp.setProperty("http://java.sun.com/xml/jaxp/properties/schemaLanguage",
    "http://www.w3.org/2001/XMLSchema");
    sp.setProperty("http://java.sun.com/xml/jaxp/properties/schemaSource", xsdPath);
    DefaultHandler dh = new DefaultHandler();
    sp.parse(splObjPath, dh);
    thanks

    Many ways to do this... also depending upon what version of Xerces and/or you want to do DTD or schema, etc one of the simplest is to set the following properties,
    refer to:
    http://xerces.apache.org/xerces2-j/features.html
    Scroll down, check all the features starting with "http://apache.org/xml/features/validation"

  • How to validate XML Schema in DOM?

    I've got an XML file and corresponding XSD file.
    How do I validate this XML file when using DOM parser?
    Thanks

    You can use the sun msv API.
    This multi schema validator can validate documents against different sorts of Schema.
    More info at http://wwws.sun.com/software/xml/developers/multischema/

  • Help: How to Validate XML using SAXParser and return the entire error list

    Hi,
    I have a problem, I'm trying to validate a xml document against the DTD. Here Im using SAXParser and having the ErrorHandler object passed when setting the error Handler, like parser.setErrorHandler(errorHandlerObj).
    I need an output like where the entire XML document is read and all the errors have to be reported with the line number.
    like example:
    <b>Line 6: <promp>
    [Error]:Element type "promp" must be declared.
    Line 8: </prompt>
    [Fatal Error]:The end-tag for element type "promp" must end with a '>' delimiter.
    who can i achieve this.</b>
    what happens with the present code is that it throws the first error it encountered and comes out.
    how can i solve this problem

    You can try to set the following feature to 'true' for your SAXParser:
    http://apache.org/xml/features/continue-after-fatal-error
    At least Xerces supports this feature.

  • Need help - How to Validate XML

    I have just started playing around with XML in Flex2 and
    can't figure out a few things. I have the following XML
    var myData:XML =
    <SPECIAL>
    <ROW>
    <ITEM_001 ITEM_NAME="TOLERANCE">10</ITEM_001>
    <ITEM_002 ITEM_NAME="DIA A">.25</ITEM_002>
    <ITEM_003 ITEM_NAME="DIA B">.5</ITEM_003>
    </ROW>
    <ROW>
    <ITEM_001 ITEM_NAME="TOLERANCE">150</ITEM_001>
    <ITEM_002 ITEM_NAME="DIA A">.25</ITEM_002>
    <ITEM_003 ITEM_NAME="DIA B">.73</ITEM_003>
    </ROW>
    </_SPECIAL>
    I want the extract the element name ITEM_00x from with the
    row to use as a string in another portion of the app. For example,
    I can get to the ITEM_NAME attribute (TOLERANCE) and to the value
    (like 10). I can't figure out how to extract ITEM_001 short of
    creating an XMLString and parsing it out. I'm sure there must be a
    function or some other simple way to get it but I don't know what
    it is.
    Another thing I'd like to do is validate the xml somehow so I
    can insure that I have a good format. Not sure how to do this in
    Flex2. I'm uploading XML via HTTPService (e4X format) from users.
    The only caveat is that the number of elements in each row can vary
    depending on whom I get the xml from. I may have ITEM_001 thru
    ITEM_010 in each row the first time and ITEM_001 thru ITEM_005 the
    next.
    Any help would be appreciated!
    Warren Koch

    That didn't do it -- it just extracted "TOLERANCE", not
    "ITEM_001". What I'm trying to do is create an array of objects
    based on the XML. Here is the code:
    public function CreateSpecialDataArray():Array {
    var Data_Name:String;
    var theData:Array = new Array();
    var DataObject:Object;
    for each (var propRow:XML in myData.SPECIAL.ROW) {
    DataObject = new Object();
    for each (var propItem:XML in propRow.*) {
    Data_Name = propItem.@ITEM_NAME;
    DataObject[Data_Name]=propItem.toString();
    theData.push(DataObject);
    It's making the DataObject with properties of TOLERANCE, etc.
    I want to make the DataObject with properties of ITEM_001,
    ITEM_002, etc. I can't use the @ITEM_NAME to do this.

  • 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 validate xml document again schema

    I need to create an xml document from sql retrieval. This xml document needs to be validated by xslt and xsd.
    The problem that I am having is that with some criteria, that xml document passed the validation, while others do not.
    Is there a way to check the xml document against the xsd to see which record does not pass the validation? Thanks.

    http://www.oracle.com/technology/pub/articles/vohra_xmlschema.html

Maybe you are looking for

  • Can you open more than one ER file at a time?

    I was wondering if you can open more than one file at a time in ER? I attempted it, however, it does not appear that I can do that like other Adobe products.  (If not, it would be  nice to have the ability of working, or opening more than one file at

  • Adobe XI Pro Installing Error 1935

    I tried to download trial Adobe Acrobat XI Pro but this message keeps appear. I used Chrome to download the Adobe Download Assistant. I have Windows 7. Please help me on this problem.

  • Adobe flash player 11.5.5

    why ie-10/window 8/msn search is not upatable to adobe flash player 11.5.5?

  • Physical and Logical Partioning

    Hi Friends,            I would like to know what is the difference between these 2 types of partioning?? Is there any OSS notes to gain knowledge on this?? thanks,

  • Device deployment requires AIR SDK 3.4 or above

    I've just installed FB 4.7 (OS X 10.7.5) and followed "Update the AIR SDK" instructions (ignoring step 2) and installed AIR 3.5.0.890 SDK. I then create my run configuration (targeting Apple iOS) with the "Install the application on the device over U