Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: Dependencies between attributes and elements

From: Andy Den Tandt <andydt@-------.-->
To: =?ISO-8859-1?Q?Jo=E3o_Cruz_Morais?= <napalm@----------.--->
Date: 8/7/2007 2:46:00 PM

I'm struggling with a similar issue. As I understand it, you can't do it 
with a custom attribute, but you can use xsi:type provided you 
(manually) define all the types you want to support in your schema.

<vector xsi:type="intvector"> <!-- and in schema define complextypes intvector, stringvector, numbervector, ... and even intpair, inttriple, ... -->
  <value>2</value> <!-- if not int throws a error -->
</vector>

But it has drawbacks: you have to define all of the types and you have 
to change the XML to use xsi:type instead of your own attribute.

Kind regards,

Andy Den Tandt




João Cruz Morais wrote:
> Thanks for your answer Michael, I think I'll deal with the document
> structure with XSD and do the remaining validation in my java app.
> One more thing though:
>
> Right now I'm using an element called int-vector to specify a list of
> int values. Is it possible to make that element go away and replace it
> for a generic one, with an attribute specifying the vector type? In
> other words is it possible to establish a relationship between the
> value of an element attribute and his children?
> Example:
>
> <vector type="int">
>   <value>2</value> <!-- if not int throws a error -->
> </vector>
>
> Thanks a lot,
> João
>
> On 06/08/07, Michael Kay <mike@s...> wrote:
>   
>>> Given this simple xml:
>>>
>>> <vector size="2">
>>>   <value>1</value>
>>>   <value>3</value>
>>> </vector>
>>>
>>> Is there a way to validate the number of <value> elements
>>> according to the vector size attribute?
>>> I'm tempted to say no, so should I make this kind of
>>> validation inside my program?
>>>       
>> XML Schema 1.1 will add this capability using assertions:
>>
>> <xs:assert test="count(value) = @size"/>
>>
>> Meanwhile you have to resort to other approaches, e.g. your own validation
>> code in XSLT, or Schematron.
>>
>> Michael Kay
>> http://www.saxonica.com/
>>
>>
>>     
>
>
>   

From mike@s... Tue Aug 07 11:21:44 2007
Received: from aji.w3.org ([133.27.228.225])
	by frink


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