Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8800329
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T00:33:36+00:00 2026-06-14T00:33:36+00:00

I would like to ask a question about XML document validation against its corresponding

  • 0

I would like to ask a question about XML document validation against its corresponding XML schema(s) and I would appreciate if you could kindly give me a hand. Actually, I’ve just started learning about XML schemas (I’m totally a beginner). I’ve purchased the book "Definitive XML Schema" written by Priscilla Walmsley (2nd Edition) which presents XML Schema 1.1 (which I believe is the most recent version).

Now the problem is that in all examples and exercices of the book, the namespaces and location of the schema files are given using a web URL.

Here is an example of the book:

This is the schema

<xs:schema  xmlns:xs="http://www.w3.org/2001/XMLSchema"
            targetNamespace="http://datypic.com/prod"
            xmlns:prod="http://datypic.com/prod">
        
    <xs:element name="product" type="prod:ProductType"/>
    <xs:complexType name="ProductType">
        <xs:sequence>
            <xs:element name="number" type="xs:integer"/>
            <xs:element name="size" type="prod:SizeType"/>
        </xs:sequence>
        <xs:attribute name="effDate" type="xs:date"/>
    </xs:complexType>
    <xs:simpleType name="SizeType">
        <xs:restriction base="xs:integer">
            <xs:minInclusive value="2"/>
            <xs:maxInclusive value="18"/>
        </xs:restriction>
    </xs:simpleType>
</xs:schema>

And the XML content to be validated against the above mentioned is this

<prod:product xmlns:prod="http://datypic.com/prod" 
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://datypic.com/prod prod.xsd"
          effDate="2011-04-12">
    <number>557</number>
    <size>10</size>
</prod:product>

Obviously, [http://datypic.com/prod] is a site maintained by the author, so I cannot add or DELETE any file on this site for my exercices while I’m reading this book. As a result I need to put both XML and XSD documents on my local hard drive (I’m using Linux Fedora Core 17 X86_64). So what I did, was to put the content of the schema in a file named for example ‘Example-01.xsd‘ and the XML content in a file named ‘Example-01.xml‘.

I use oracle PL/SQL package DBMS_XMLSCHEMA (Enterprise Edition 11.2.0.1.0) in order to first register the schema and then call the validate method of XMLType object in order to validate my XML document against the schema, similar to the following link:

https://forums.oracle.com/forums/thread.jspa?messageID=2462207

I have created a directory (by CREATE DIRECTORY) statement in oracle :

/home/train/Documents/myutl_file_dir/

Where I put both my XML & XSD documents. Here is precisely how I changed the above mentioned XML content in order to refer to XSD locally

<prod:product xmlns:prod="http://datypic.com/prod" 
              xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
              xsi:schemaLocation="http://datypic.com/prod file:///home/train/Documents/myutl_file_dir/Example-01.xsd"
               effDate="2011-04-12">
    <number>557</number>
    <size>10</size>
</prod:product>

So if you compare the new XML content with the above mentioned example, the only thing that I added was file:///home/train/Documents/myutl_file_dir/Example-01.xsd at the end of the value of xsi:schemaLocation in order to refer to the local hard drive. I found this method, here:

http://lists.w3.org/Archives/Public/xmlschema-dev/2001Dec/0161.html

Now, the problem is that it doesn’t work. When I run my script in order to validate the document by calling the schemaValidate() method of the XMLType object, here is oracle error message:

BEGIN
*
ERROR at line 1:
ORA-19030: Method invalid for non-schema based XML Documents.
ORA-06512: at "SYS.XMLTYPE", line 354
ORA-06512: at "TRAIN2012.ZXML_PKG", line 176
ORA-06512: at line 2

What I understand from the error message Method invalid for non-schema based XML Documents is that Oracle has simply ignored the filepath that I defined for schema file and it considers that there has not been any schema declared for this XML document.

Any idea? How can I deal with this problem?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T00:33:38+00:00Added an answer on June 14, 2026 at 12:33 am

    OK, after a lot of Googling and thanks to stefan nebesnak’ comment I found two problems that caused the error:

    The first one, as Stefan mentioned is that DBMS_XMLSCHEMA.registerSchema can be applied only to schema-based document. Initially what I had done in my PL/SQL code was something like this:

    l_xml_file_content := XMLType('Here I put the content of my XML document')
    l_xml_file_content.schemaValidate();
    

    So as you can see there is absolutely no link between the registered schema and the XMLType object that refers to my XML document. What I had to do was this:

    l_xml_file_content := 
       XMLType(
                'Here I put the content of my XML document'
              ).createSchemaBasedXML('and here I put the very same schema URL used during registereation while I registered the schema by calling the DBMS_XMLSCHEMA.registerSchema method')
    

    So, the first problem was solved and my XML document became a schema-based.

    The second problem was the fact that in the book the XML document to be validated against the schema had been defined in following way:

    <prod:product xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                  xmlns:prod="http://datypic.com/prod"
                  xsi:schemaLocation="http://datypic.com/prod prod.xsd" 
                  effDate="2011-04-12">
    
        <number>557</number>
        <size>10</size>
    </prod:product>
    

    What I understood from ‘xsi:schemaLocation=”http://datypic.com/prod prod.xsd”‘ was that the first part of it, that is, http://datypic.com/prod refers to the targetNameSpace and the second part separated by a space, that is, prod.xsd, is used
    to refer to the location (as an URL) of the schema document which is true. But what I didn’t know, was that in oracle DBMS_XMLSCHEMA implementation, this second part must be the very same URL used to register the schema by calling DBMS_XMLSCHEMA.RegisterSchema method, otherwise it will not work. And here is the link to the oracle documentation that confirms this:

    http://docs.oracle.com/cd/B19306_01/appdev.102/b14259/xdb03usg.htm#BABBGBDA

    If the target XML schema declares a target namespace, then the schemaLocation attribute is used to identify the XML schema. The value of this attribute is a pair of values separated by a space:

    • the value of the target namespace declared in the XML schema
    • the schema location hint, the unique identifier passed to procedure DBMS_XMLSCHEMA.registerSchema when the schema is registered with the database

    And that was precisely what I hadn’t done, I had registered the schema with ‘http://datypic.com/prod‘ and just because in the book there was a file name as the second part of the xsi:schemaLocation (prod.xsd) I thought that all I had to do was to put the schema content in a file named for example Example-01.xsd and then provide the file URL to this document, file:///home/train/Documents/myutl_file_dir/Example-01.xsd. Which was really a silly thing because, when you register a schema with oracle by calling the DBMS_XMLSchema.registerSchema, oracle registers the content of the XML schema document. So what oracle needs is the schemaURL used during registeration which allows to find and identify uniquely the specific schema. And this was exactly my mistake I had thought that oracle is looking for physical location of my file.

    Conclusion: I had registered the schema by the targetNameSpace : ‘http://datypic.com/prod’ (well, it was just an example, I could have chosen other value)

    So, the correct value of schemaLocation inside my XML document was this:

    xsi:schemaLocation="http://datypic.com/prod prod.xsd 
                        http://datypic.com/prod prod.xsd"
    

    And this solved the problem.

    I hope this can help those who have encountered the same problem.

    Regards,

    Dariyoosh

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i would like to ask a question about @UsesJAXBContext annotation in jax-ws. I try
I would like to ask such question, I have XML xsd`s, which generate beans
I would like to ask a question about correct way of canceling socket operations
I would like to ask a question about a new and large scale web
I would like to ask a theoritical question about how some web sites work.
I would like to ask you a question about implementing mutual authentication with Kerberos,
I would like to ask a question. Now i'm training about iPhone Programming. I'm
I would like to ask you a question about logging provided jars. I have
I would like to ask a question about triggers. Let's say that I have
I would like to ask a fundamental question about when is it useful to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.