Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > Complex attribute defaults?

Reply
Thread Tools

Complex attribute defaults?

 
 
Robert William Vesterman
Guest
Posts: n/a
 
      12-19-2004
Is there a way to say, in a DTD things like:

(1) The default value of attribute X is the value of attribute Y?

(2) The default value of attribute X is the value of attribute Y
appended by the text "BLAH"?

(3) The default value of attribute X is "BLAH" if attribute Y has
value "BLING", or "BOING" otherwise?

(4) The default value of attribute X is "BLAH" if attribute Y is
present, or "BOING" otherwise?

Or various other possibilities beyond the simple "the default value is
such-and-such and that's all there is to it"?

If I need such concepts, and it's not possible, obviously I have to do
them at the application level, and pretend at the XML level that
they're just "#IMPLIED". Is that somehow considered an invalid,
incorrect, impure, evil, or otherwise negative thing to do?

Thanks,

Bob Vesterman.
 
Reply With Quote
 
 
 
 
David Carlisle
Guest
Posts: n/a
 
      12-21-2004


> Is there a way to say, in a DTD things like:
> ...

No

> If I need such concepts, and it's not possible, obviously I have to do
> them at the application level, and pretend at the XML level that
> they're just "#IMPLIED". Is that somehow considered an invalid,
> incorrect, impure, evil, or otherwise negative thing to do?


It's the way life is. It's certainly not invalid, I leave others to
judge harder concepts such as impurity or evil

David
 
Reply With Quote
 
 
 
 
Peter Flynn
Guest
Posts: n/a
 
      12-31-2004
Robert William Vesterman wrote:

> Is there a way to say, in a DTD things like:
>
> (1) The default value of attribute X is the value of attribute Y?


In a *DTD*, yes, but only by hardcoding it

<!ATTLIST foo X (a|b|c) "c" Y (c) "c">

A default token list value must be a literal: it can't be a parameter
entity, so it's not possible to hard-code it.

But I find it hard to imagine a circumstance where you want to do this.
Can you explain more? I think you mean that you want to do this in an
XML document instance.

> (2) The default value of attribute X is the value of attribute Y
> appended by the text "BLAH"?


The same answer.

> (3) The default value of attribute X is "BLAH" if attribute Y has
> value "BLING", or "BOING" otherwise?
>
> (4) The default value of attribute X is "BLAH" if attribute Y is
> present, or "BOING" otherwise?


No. You have to use a Schema if you want this level of validation.

> Or various other possibilities beyond the simple "the default value is
> such-and-such and that's all there is to it"?
>
> If I need such concepts, and it's not possible, obviously I have to do
> them at the application level, and pretend at the XML level that
> they're just "#IMPLIED". Is that somehow considered an invalid,
> incorrect, impure, evil, or otherwise negative thing to do?


No, just that DTDs were designed for TEXT documents, not DATA, so
cross-validation of attribute values was not an issue, as it arises
so rarely in normal text documents.

///Peter
--
"The cat in the box is both a wave and a particle"
-- Terry Pratchett, introducing quantum physics in _The Authentic Cat_
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Complex attribute with Attribute and simpletype kanpeter XML 0 10-26-2010 09:41 AM
How complex is complex? Kottiyath Python 22 03-28-2009 10:11 PM
wsdl2java: method parameter a complex type that extends another complex type Robert Mark Bram Java 0 02-04-2007 10:06 AM
[XML Schema] Content type of complex type definition with complex content Stanimir Stamenkov XML 2 10-25-2005 10:16 AM
For expert on complex loops (reposted) - complex looping problem news.amnet.net.au Java 1 04-13-2004 07:10 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57