prafullagrawal
prafullagrawal

Reputation: 31

How to appropriately include schemalocation to refer a xsd file in xml

I am building a xml grammar file for speech recognition so for that I created a lexicon file and added lexicon elements as follows the schema location giving me errors

  1. the schema referenced from this location in your document contains error
  2. the operation has timed out

The bolded line is causing the error

xmlns="http://www.w3.org/2005/01/pronunciation-lexicon"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.w3.org/2005/01/pronunciation-lexicon
**http://www.w3.org/TR/2007/CR-pronunciation-lexicon-20071212/pls.xsd"**
alphabet="x-microsoft-ups" xml:lang="en-IN"

What should I do?

Upvotes: 0

Views: 1754

Answers (1)

Petru Gardea
Petru Gardea

Reputation: 21658

The schema you're pointing at is valid. The thing is, schemas hosted on the W3C website are sometimes throttled; more so in your case since pls.xsd references xml.xsd (this one for sure is throttled).

W3C throttles responses to well know XSDs as means to protect itself against unnecessary traffic.

Download your local copy and reference those instead, and all should be fine (assuming everything else works for you).

This is how the XML file should look like based on your comments:

<?xml version="1.0" encoding="utf-8"?> 
<lexicon version="1.0" 
    xmlns="http://www.w3.org/2005/01/pronunciation-lexicon" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.w3.org/2005/01/pronunciation-lexicon file://C:/some/folder/where/your/xsd/file/is/pls.xsd" 
    alphabet="x-microsoft-ups" xml:lang="en-IN">
    <lexeme>

    </lexeme>
</lexicon>

This is how the pls.xsd top part should look like (after changing the schema location for xml.xsd, assume they are in the same folder):

<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<!-- Externals changed by QTAssistant (http://www.paschidev.com) -->

<!--
  This is a draft schema for the XML language defined in the 
  Pronunciation Lexicon Specification 
  (latest version at <http://www.w3.org/TR/pronunciation-lexicon/>)
  At the time of writing, the specification as well as this schema are
  subject to change, and no guarantee is made on their accuracy or the fact
  that they are in sync.
  Last modified: $Date: 2007/12/11 12:08:40 $

  Copyright &#251; 2006 World Wide Web Consortium, (Massachusetts Institute
  of Technology, ERCIM, Keio University). All Rights Reserved. See
        http://www.w3.org/Consortium/Legal/.
-->
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:p="http://www.w3.org/2005/01/pronunciation-lexicon" targetNamespace="http://www.w3.org/2005/01/pronunciation-lexicon" elementFormDefault="qualified" version="1.0">
    <xs:annotation>
        <xs:documentation>Importing dependent namespaces</xs:documentation>
    </xs:annotation>
    <xs:import namespace="http://www.w3.org/XML/1998/namespace" schemaLocation="xml.xsd" />

 ...
    </xs:schema>

It all works fine in VS2010 and up.

Upvotes: 1

Related Questions