0

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?

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459

1 Answers1

1

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.

Petru Gardea
  • 21,373
  • 2
  • 50
  • 62
  • thank you sir...after changing xml as you shown it causes error saying An error has occurred while opening external DTD 'file:///C:/xsdforproject/XMLSchema.dtd': Could not find file 'C:\xsdforproject\XMLSchema.dtd – prafullagrawal Feb 05 '14 at 19:06
  • What tool are you using? The XSD files we're talking about don't reference the DTDs you're referring... your problems are most likely of a different nature. – Petru Gardea Feb 05 '14 at 19:12
  • Yah i know thatsy i am also confused about dtd error...i am working on VS2010 – prafullagrawal Feb 05 '14 at 19:24
  • You're having unrelated problems... I've tried the files as posted in VS2010 and everything works fine (Intellisense, validation, etc.) You'll have to look elsewhere, ideally try a repro of some sort and post a different question... – Petru Gardea Feb 05 '14 at 19:31
  • Sir is there any problem in my c# code I mean that this problem has anything to do with in coding? – prafullagrawal Feb 10 '14 at 17:30
  • What C# code are you refering to? You did not post any. – Petru Gardea Feb 10 '14 at 19:05
  • I am using following c# code to read & use my XML file. string srgsDocumentFile=Path.Combine(@"Voice_Automator.xml"); XmlReader reader = XmlReader.Create(srgsDocumentFile); SrgsDocument t1 = new SrgsDocument(reader); Grammar g1 = new Grammar(t1); _recognizer.LoadGrammarAsync(g1); – prafullagrawal Feb 11 '14 at 15:26
  • It doesn't make sense... Loading an XML referencing an XSD doesn't trigger validation - there's something else you're not showing. Try to create your XmlReader using this [API](http://msdn.microsoft.com/en-us/library/ms162474(v=vs.110).aspx). On .NET 4.0 and above set [DtdProcessing](http://msdn.microsoft.com/en-us/library/system.xml.xmltextreader.dtdprocessing(v=vs.100).aspx) to Ignore; on earlier versions, set [ProhibitDtd](http://msdn.microsoft.com/en-us/library/system.xml.xmlreadersettings.prohibitdtd(v=vs.110).aspx) to false. – Petru Gardea Feb 12 '14 at 02:33
  • now see sir is it right? string srgsDocumentFile = Path.Combine(@"Voice_Automator.xml"); XmlReaderSettings settings = new XmlReaderSettings(); XmlUrlResolver resolver = new XmlUrlResolver(); resolver.Credentials =System.Net.CredentialCache.DefaultCredentials; settings.XmlResolver = resolver; settings.DtdProcessing = DtdProcessing.Parse; settings.ValidationType = ValidationType.Schema; XmlReader reader = XmlReader.Create(srgsDocumentFile, settings); SrgsDocument t1 = new SrgsDocument(reader); Grammar g1 = new Grammar(t1); _recognizer.LoadGrammarAsync(g1); – prafullagrawal Feb 12 '14 at 08:31
  • `settings.DtdProcessing = DtdProcessing.Parse` is wrong; as indicated, use Ignore instead. – Petru Gardea Feb 13 '14 at 14:13