如何声明元素 [英] How to declare element
问题描述
我正在寻找使用 xrm
前缀验证 XML 文档,您可以在此处阅读:
I'm looking for validate an XML document with xrm
prefix as you can read here :
我编写了以下 XML 架构:
I wrote the following XML Schema :
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
</xsd:schema>
但是,当我检查 XML 文档时,出现以下错误:
However, when I check my XML document, I get the following error:
'xrm:plugin' 不是 'NCName' 的有效值
'xrm:plugin' is not a valid value for 'NCName'
我知道我不能将 xrm:
放在我的名字中,但是我如何验证我的 xrm:plugin
和 xrm:header
?因为,如果我尝试验证我的 XML 文档,我会收到以下错误:
I understand I can't put xrm:
in my name, but how can I validate my xrm:plugin
and xrm:header
?
Because, if I try to validate my XML document, I get this error:
找不到元素xrm:plugin"的声明.
Cannot find the declaration of element 'xrm:plugin'.
推荐答案
xrm
是命名空间前缀,是命名空间的缩写.如语法错误所示,名称空间前缀未通过 xsd:element/@name
声明.相反,仅声明本地名称 (plugin
) 并在 XSD 级别处理命名空间前缀声明...
xrm
is a namespace prefix, an abbreviation for the namespace. As the syntax error indicates, a namespace prefix is not declared via xsd:element/@name
. Instead, declare only the local name (plugin
) and handle the namespace prefix declaration at the XSD level...
以下是您的 XML 和 XSD 的简化集,其中 XML 已根据 XSD 成功验证:
Here is a simplified set of your XML and XSD where the XML validates successfully against the XSD:
<?xml version="1.0" encoding="UTF-8"?>
<xrm:plugin xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.moss.fr/2011/connecteur_xrm result.xsd"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xrm="http://www.moss.fr/2011/connecteur_xrm">
<xrm:header>
<xrm:tracabilite>
<xrm:reference_moss>MPD_4.1.1.0</xrm:reference_moss>
<xrm:document_lie> </xrm:document_lie>
<xrm:document_interface>SC-DIF-OT3402-0002-MOSS 1.8 - DIF COSCA Inc.2.doc</xrm:document_interface>
<xrm:intervention>
<xrm:auteur>Générateur de mapping v1.0</xrm:auteur>
<xrm:date>14/01/2013</xrm:date>
<xrm:commentaire>Génération du fichier de mapping</xrm:commentaire>
</xrm:intervention>
</xrm:tracabilite>
</xrm:header>
</xrm:plugin>
XSD
<?xml version="1.0" encoding="utf-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xrm="http://www.moss.fr/2011/connecteur_xrm"
xmlns:SCCOAMCD="urn:SCCOA-schemaInfo"
xmlns:SBEGestionZonesAeriennesSYSCA="urn:SBEGestionZonesAeriennesSYSCA-schema"
SCCOAMCD:desc=" implémentation du MCD pivot du SCCOA 3.2.1ec production par SCCOA mcd2mpd 4.1.1, le 11/12/2007 règles spécifiques production schémas 1.2 diagramme : A-SC.SBE GestionZonesAeriennes SYSCA entité racine : A-SC.ZoneAerienne "
attributeFormDefault="unqualified"
elementFormDefault="qualified"
targetNamespace="http://www.moss.fr/2011/connecteur_xrm"
version="3.2.1ec">
<xsd:complexType name="header">
<xsd:sequence>
<xsd:any minOccurs="1" processContents="lax"/>
</xsd:sequence>
</xsd:complexType>
<xsd:element name="plugin">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="header" type="xrm:header"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
这篇关于如何声明元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!