Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: Applying Restrictions to XML Attributes

From: usenet@--------------.---
To: NULL
Date: 2/1/2008 2:07:00 AM
On 1 Feb, 07:49, Pavel Lepin <p.le...@ctncorp.com> wrote:
> mnicke...@gmail.com <mnicke...@gmail.com> wrote in
> <f0461272-9799-42a5-a909-1673f4256...@d70g2000hsb.googlegroups.com>:
>
> > I'm still learning, so apologies if this is trivial...
>
> ...
>
> > <Record>
> > =A0 =A0<foo id=3D"a">... </foo>
> > =A0 =A0<foo id=3D"b">....</foo>
> > =A0 =A0<foo id=3D"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 )?
>
> It is possible.
>
=2E..
> =A0 <xs:element name=3D"foo">
> =A0 =A0 <xs:complexType>
> =A0 =A0 =A0 <xs:simpleContent>
> =A0 =A0 =A0 =A0 <xs:extension base=3D"xs:string">
> =A0 =A0 =A0 =A0 =A0 <xs:attribute ref=3D"id" use=3D"required"/>
> =A0 =A0 =A0 =A0 </xs:extension>
> =A0 =A0 =A0 </xs:simpleContent>
> =A0 =A0 </xs:complexType>
> =A0 </xs:element>
> =A0 <xs:attribute name=3D"id">
> =A0 =A0 <xs:simpleType>
> =A0 =A0 =A0 <xs:restriction base=3D"xs:string">
> =A0 =A0 =A0 =A0 <xs:pattern value=3D"(a|b|c)"/>
> =A0 =A0 =A0 </xs:restriction>
> =A0 =A0 </xs:simpleType>
> =A0 </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.

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.
For example, as we all know, a simple way to make an XML instance
namespace qualified is to use the default namespace (xmlns=3D"foo"), and
that could potentially be a simple localized fix.  But unqualified
attributes always belong to no namespace, so this wouldn't fix the
attributes, and a more detailed fix-up would be required.

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

Pete Cordell
Codalogic
Visit http://www.codalogic.com/lmx/ for XML C++ data binding


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