Add schema to xml document


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: Add schema to xml document

  1. #1
    Join Date
    Oct 2007
    Posts
    1

    Add schema to xml document

    This may be a trivially simple question, but for some reason I can't get it to work or find the basic information on how to do it

    I have an xml document and an xml schema file and I'd like to add a reference to the schema file in the xml document

    In the root element of my xml document, I have the following:

    <TXLife Version="2.16.00" xmlns="http://ACORD.org/Standards/Life/2" schemaLocation="CITS_PendingExtractSchema.xsd">

    The namespace is correct and the schema file is in the same directory as the xml file, but the file isn't being validated against the schema.

    What is it that I'm doing wrong here?

  2. #2
    Join Date
    Sep 2011
    Posts
    1

    the solution

    Hey Tom,
    I am sure, you probably don't need this anymore, as you post was almost 4 years ago, but I stumbled upon it, as I was looking for something related. I just want to post the answer here, so if another person comes by looking for the same thing, they will find the answer here.

    You have to define the namespace via
    Code:
    xsi:noNamespaceSchemaLocation="..."
    and for this you need to add the namespace declaration
    Code:
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    So your solution would be:
    Code:
    <TXLife Version="2.16.00" xmlns="http://ACORD.org/Standards/Life/2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
     xsi:noNamespaceSchemaLocation="CITS_PendingExtractSchema.xsd">

    To all of you who still read this: when you post a question in a forum and find the answer yourself before someone in the forum does, post your answer there as well, so people who will find your question years later, because they have a similar problem and search for it, will see your correct answer and it will probably help them right away.
    Regards
    Tom

  3. #3
    Join Date
    Apr 2007
    Location
    Sterling Heights, Michigan
    Posts
    8,663
    Quote Originally Posted by TomTest View Post
    To all of you who still read this: when you post a question in a forum and find the answer yourself before someone in the forum does, post your answer there as well, so people who will find your question years later, because they have a similar problem and search for it, will see your correct answer
    Here here!

Similar Threads

  1. Validating XML fragment against schema
    By teclioness in forum .NET
    Replies: 0
    Last Post: 10-07-2005, 08:10 AM
  2. Replies: 1
    Last Post: 09-15-2005, 01:44 PM
  3. Displaying XML Data using .Net Controls
    By Greg Rothlander in forum ASP.NET
    Replies: 1
    Last Post: 11-27-2001, 07:09 PM
  4. Replies: 2
    Last Post: 03-20-2001, 02:08 PM
  5. Check out Turbo XML
    By Sales in forum xml.announcements
    Replies: 0
    Last Post: 07-20-2000, 07:18 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center