简体   繁体   English

我可以使我的XML Schema(XSD)为我提供带有* any *名称的元素的VS Intellisense吗?

[英]Can I make my XML Schema (XSD) give me VS Intellisense with elements that have *any* name?

Below is a sample XSD and sample XML. 以下是示例XSD和示例XML。 The XSD is written for XML like this: XSD是为XML编写的,如下所示:

<Columns>
    <Column label="etc..."></Column>
</Columns>

I would like the XSD to allow elements with any name instead of just "Column". 我希望XSD允许具有任何名称的元素,而不仅仅是“ Column”。 What I really want is intellisense to work in Visual Studio so that I can enter any element name instead of "Column" and still get prompted for the various column attributes. 我真正想要的是在Visual Studio中工作的intellisense,这样我可以输入任何元素名称而不是“ Column”,并且仍然会提示您输入各种列属性。 Is this possible? 这可能吗? I'm just looking for intellisense. 我只是在寻找智能感知。 I don't need to actually validate the XML using the schema. 我实际上不需要使用该模式来验证XML。

Sample XML: 样本XML:

<?xml version="1.0" encoding="utf-8" ?>
<Columns name="FindPatient" label="Find Patient">
    <Name label="Patient Name" display="yes" order="1"/>
    <MRN label="MRN #" display="yes" order="2"/>
    <BirthDate label="Birth Date" format="shortdate" align="right" display="yes" order="3"/>
    <SSN label="SSN" format="hiddenSsn" display="yes" order="4" notSortable="yes"/>
    <DateOfService label="Date Of Service" format="shortdate" align="right" display="no" order="5"/>
    <AdmitDate label="Admit Date" format="shortdate" align="right" display="no" order="6"/>
    <DischargeDate label="Discharge Date" format="shortdate" align="right" display="no" order="7"/>
    <Address label="Address" display="yes" order="8"/>
    <Facility label="Facility" display="yes" order="9"/>
</Columns>

Sample XSD: 样本XSD:

<?xml version="1.0" encoding="utf-8"?>
<xs:schema id="ColumnConfiguration" targetNamespace="http://example.com/columnconfiguration" xmlns="http://example.com/columnconfiguration" xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
    <xs:simpleType name="yesNo">
        <xs:restriction base="xs:string">
            <xs:enumeration value="yes"/>
            <xs:enumeration value="no"/>
        </xs:restriction>
    </xs:simpleType>
    <xs:complexType name="Column">
        <xs:attribute name="label" type="xs:string" use="required"/>
        <xs:attribute name="display" type="yesNo" use="required"/>
        <xs:attribute name="order" type="xs:integer" use="required"/>
        <xs:attribute name="format" type="format" use="optional"/>
        <xs:attribute name="align" type="xs:string" use="optional"/>
        <xs:attribute name="tooltip" type="xs:string" use="optional"/>
    </xs:complexType>
    <xs:complexType name="Columns">
        <xs:sequence>
            <xs:element name="Column" type="Column" minOccurs="1" maxOccurs="unbounded"/>
        </xs:sequence>
    </xs:complexType>
    <xs:element name="Columns" type="Columns"/>
</xs:schema>

replace 更换

<xs:complexType name="Columns">
    <xs:sequence>
        <xs:element name="Column" type="Column" minOccurs="1" maxOccurs="unbounded"/>
    </xs:sequence>
</xs:complexType>

with

solution : allow any child element without specifying them 解决方案:允许任何子元素而不指定它们

<xs:complexType name="Columns">
    <xs:sequence>
        <xs:any minOccurs="1"/>
    </xs:sequence>
</xs:complexType>

solution 2 : allow some well defined childs 解决方案2:允许定义明确的孩子

<xs:complexType name="Columns">
    <xs:choice minOccurs="1" maxOccurs="unbound">
        <xs:element name="Column" type="Column" minOccurs="1" maxOccurs="unbounded"/>
        <!-- add other xs:element here -->
    </xs:choice>
</xs:complexType>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 IntelliSense 在 VS2019 中不适用于我的 XML 文档,我附加了一个架构 - IntelliSense is not working in VS2019 for my XML document to which I have a schema attached 我可以让一个XML Schema(XSD)包含另一个XML-Schema吗? - Can I have one XML Schema (XSD) include another XML-Schema? 如何在xsd模式中定义XML元素以使所有子元素具有相同的属性值? - How to define XML element in xsd schema to make all child elements to have same attribute value? 多个XML元素的XSD架构,至少有一个以任意顺序存在 - XSD schema for multiple XML elements with at least one present, in any order 定义 XML 架构时,“选择”“组”元素是否有效(XSD) - Is it valid to have a 'choice' of 'group' elements when defining an XML Schema (XSD) 如何使用XSD / XML Schema约束XML元素以包含有限长度的字符串内容? - How can I use XSD / XML Schema to constrain an XML element to have string content of limited length? 能否设置我的 XSD 架构,以便命名空间元素对经过验证的 XML 显示为全局元素? - Can my XSD schema be set up so namespace elements appear as global to validated XML? xml模式xsd任何元素 - xml schema xsd any element XML模式:具有此名称模式的元素具有此属性 - XML Schema: elements with this name pattern have this attribute 给出此xsd模式文件的简单xml示例 - give a simple xml example for this xsd schema file
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM