Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: Applying Restrictions to XML Attributes

From: Pavel Lepin <p.lepin@-------.--->
To: NULL
Date: 2/1/2008 12:23:00 PM


usenet@t... <usenet@t...> wrote
in
<8f2742d7-79d0-4c33-bb39-3dcfb92d3362@e...>:
> On 1 Feb, 07:49, Pavel Lepin <p.le...@ctncorp.com> wrote:
>> mnicke...@gmail.com <mnicke...@gmail.com> wrote:
>> > <Record>
>> > <foo id="a">... </foo>
>> > <foo id="b">....</foo>
>> > <foo id="c">.....</foo>
>> > </Record>
>>
>> > Is it possible to create an xsd file that enforces that
>> > within the <Record> block there exists exactly three
>> > foo tags each containing a different id value (from the
>> > enum a, b, and c )?
>
>> <xs:element name="foo">
>> <xs:complexType>
>> <xs:simpleContent>
>> <xs:extension base="xs:string">
>> <xs:attribute ref="id" use="required"/>
>> </xs:extension>
>> </xs:simpleContent>
>> </xs:complexType>
>> </xs:element>
>> <xs:attribute name="id">
>> <xs:simpleType>
>> <xs:restriction base="xs:string">
>> <xs:pattern value="(a|b|c)"/>
>> </xs:restriction>
>> </xs:simpleType>
>> </xs:attribute>
>> </xs:schema>
> 
> I don't know what other peoples' opinions are, but in
> general I think I would avoid doing a ref to an attribute. 
> My reasoninig is that in XML documents attributes are
> generally unqualified (although there are numerous
> exceptions to this such as xml:lang etc.).  If an XML
> namespace is present, then globally defined attributes 
> are namespace qualified.  Agreed, this schema does not
> define a targetNamespace, so the issue doesn't arise; at
> the moment.

Ah well, I don't really have an opinion. I simply don't
tinker all that much with schemata, so I'm a bit in the
dark as to what the corresponding best practices are. In
this case I defined the attribute separately without even
thinking twice about this (or the consequences).

> However, if as the schema is evolved it's decided to give
> it a target namespace, then the attribute will become
> qualified. This could potentially make it difficult to
> migrate any existing XML instances.

Makes sense to me. However, I believe that all newly
developed schemata should be namespaced from the start. In
that case, the issue would have been immediately obvious
anyway.

> Just my thought - and I'd interested to hear others!

Having thought about it for some five-ten minutes I tend to
agree in general. Defining attributes separately and
referring to them in element definitions should probably be
avoided, unless there's a very good reason for this (like,
some sort of meta-information present on many different
elements: but in that case it makes perfect sense to
namespace the attribute as well, so there).

-- 
<>There is no phenotype</>


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent