如何适当地包含架构定位以在 xml 中引用 xsd 文件 [英] How to appropriately include schemalocation to refer a xsd file in xml

查看:23
本文介绍了如何适当地包含架构定位以在 xml 中引用 xsd 文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在构建一个用于语音识别的 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. 从您文档中的此位置引用的架构包含错误
  2. 操作超时

粗体线导致错误

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"

我该怎么办?

推荐答案

您指向的架构有效.问题是,托管在 W3C 网站上的模式有时会受到限制;在你的情况下更是如此,因为 pls.xsd 引用了 xml.xsd (这个肯定被限制了).

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 限制对众所周知的 XSD 的响应,以此来保护自己免受不必要的流量的影响.

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).

根据您的评论,XML 文件应如下所示:

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>

这是 pls.xsd 顶部的样子(更改 xml.xsd 的架构位置后,假设它们在同一文件夹中):

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>

在 VS2010 及更高版本中一切正常.

It all works fine in VS2010 and up.

这篇关于如何适当地包含架构定位以在 xml 中引用 xsd 文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆