Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

XML-Schema-Problem

1 view
Skip to first unread message

Holger Boskugel

unread,
Aug 23, 2009, 9:32:59 AM8/23/09
to
Hallo in die Runde,

ich suche eine L�sung f�r folgendes XML-Problem damit es eindeutig wird:

ich habe ein Element "Account", welches zum einen Werte aus einer
Enumeration hat und andererseits auch einen String im Format
"<Domain>\<UserName>" enthalten kann, dann aber das Attribut "Password"
ben�tigt.

Bisher habe ich es nur geschafft, dass das Attribut generell optional ist.
Ich
m�chte aber erreichen, dass es immer dann "required" ist, wenn kein Wert
aus der Enumeration genommen wird und bei der Enumeration sollte dieses
Attribut fehlen. Ich m�chte auch den alternativen Weg vermeiden zwei
verschiedene Elemente in einen "choice" zu fassen.

Mein bisheriges Schema daf�r lautet so:

<xs:element name="Account" minOccurs="0" maxOccurs="1"
default="LocalService">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="Account">
<xs:attribute name="Password" type="xs:string" />
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>

<xs:simpleType name="Account">
<xs:union>
<xs:simpleType>
<xs:annotation>
<xs:documentation>Build in accounts</xs:documentation>
</xs:annotation>

<xs:restriction base="xs:string">
<xs:enumeration value="LocalService" />
<xs:enumeration value="NetworkService" />
<xs:enumeration value="LocalSystem" />
</xs:restriction>
</xs:simpleType>

<xs:simpleType>
<xs:annotation>
<xs:documentation>User accounts</xs:documentation>
</xs:annotation>

<xs:restriction base="xs:string">
<xs:pattern value="^(\.|[\w\-]{1,64})\\\.+$">
<xs:annotation>
<xs:documentation><![CDATA[<Domain>\<UserName>]]></xs:documentation>
</xs:annotation>
</xs:pattern>
</xs:restriction>
</xs:simpleType>
</xs:union>
</xs:simpleType>

F�r Anregungen und vielleicht eine L�sung w�re ich dankbar.


Viele Gr�sse aus Berlin

Holger

0 new messages