SunQuest
           XML Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreXML Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
  #1  
Old December 19th, 2001, 07:58 PM
JMM JMM is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Feb 2001
Location: USA
Posts: 830 JMM User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 17 m 56 sec
Reputation Power: 8
Redeclaring attribute in derived type (XML schema structure)

This is a question about schema structure.

Can I redeclare an attribute when deriving a complexType? For example, if I want to create a generic type that specifies a minimal content model and one or more attributes and I want to derive other types from that, adding to the content model. and restricting the value of an attribute of the base type by setting a fixed or default value or restricting the value, etc. e.g.

Code:

...

<xsd:complexType name="BaseType">

  <xsd:sequence>

    <xsd:element ref="JMM:someElementABC" />

  </xsd:sequence>

  <xsd:attribute name="id" type="xsd:ID" />

</xsd:complexType>


<xsd:complexType name="DerivedType">

  <xsd:complexContent>

    <xsd:extension base="JMM:BaseType">

      <xsd:sequence>

        <xsd:element ref="JMM:someElementXYZ" />

      </xsd:sequence>

      <xsd:attribute name="id" type="xsd:ID" fixed="Derived" />

    </xsd:extension>

  </xsd:complexContent>

</xsd:complexType>

...


The spec seems to rule this out, but it would provide a useful facility for me, and the XSV schema validator linked from the W3C schema page doesn't seem to have a problem with it.

Relevant parts of the spec:

Quote:

Complex Type Definition with simple content Schema Component

{attribute uses}

A union of sets of attribute uses as follows
1 The set of attribute uses corresponding to the <attribute> [children], if any.
...
3 if the type definition ·resolved· to by the ·actual value· of the base [attribute] is a complex type definition, the {attribute uses} of that type definition, ...



Quote:

3.4.6 Constraints on Complex Type Definition Schema Components

Schema Component Constraint: Complex Type Definition Properties Correct

All of the following must be true:

...
4 Two distinct attribute declarations in the {attribute uses} must not have identical {name}s and {target namespace}s.
...




What do you make of this?

--> Jesse

Reply With Quote
  #2  
Old December 20th, 2001, 03:00 AM
Taradino Taradino is offline
Python Prophet
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2001
Location: Amersfoort, The Netherlands
Posts: 45 Taradino User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 8
I'm not sure, and I can't find it in my favourite XML Schema guide. I don't have much time now, but I'll check some more later.

I think it's allowed because you're in an extension. You override the old attribute with this. Identical names are of course not allowed if they're in the same section.
__________________
Some people, when confronted with a problem, think “I know, I'll use regular expressions.” Now they have two problems. - Jamie Zawinski, in comp.lang.emacs

Reply With Quote
  #3  
Old December 20th, 2001, 07:36 PM
JMM JMM is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Feb 2001
Location: USA
Posts: 830 JMM User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 17 m 56 sec
Reputation Power: 8
Quote:

I think it's allowed because you're in an extension. You override the old attribute with this. Identical names are of course not allowed if they're in the same section.



I don't think that's correct because (refer to the excerpts from the spec in my original post) the constraint applies to the attribute uses, and the attribute uses for the derived type includes the attribute uses of the base type, which include any <attribute> children of the base type.

If you do have the chance to look into it, I would appreciate it. I'm also trying to get to the bottom of this on xmlschema-dev@w3.org. The spec seems to spell it out pretty clearly that you can't do it, but it seems extremely limiting, and you know how those W3C specs are -- and the schema spec is a beast.

--> Jesse

Reply With Quote
  #4  
Old December 21st, 2001, 07:21 AM
Taradino Taradino is offline
Python Prophet
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2001
Location: Amersfoort, The Netherlands
Posts: 45 Taradino User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 8
Quote:
Originally posted by JMM


I don't think that's correct because (refer to the excerpts from the spec in my original post) the constraint applies to the attribute uses, and the attribute uses for the derived type includes the attribute uses of the base type, which include any <attribute> children of the base type.

If you do have the chance to look into it, I would appreciate it. I'm also trying to get to the bottom of this on xmlschema-dev@w3.org. The spec seems to spell it out pretty clearly that you can't do it, but it seems extremely limiting, and you know how those W3C specs are -- and the schema spec is a beast.

--> Jesse


I saw your post there and the reply by Jeni, and I'm not so sure, I can't find the answer anywhere. I have asked another guy(always well informed about XML and the surrounding technologies), and he's also looking into it.

Reply With Quote
  #5  
Old December 21st, 2001, 09:06 AM
JMM JMM is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Feb 2001
Location: USA
Posts: 830 JMM User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 17 m 56 sec
Reputation Power: 8
OK, thanks Taradino. Hopefully we can figure this out. I'm not saying she's wrong, but I'm not confident that Jeni's answer was right -- if you can't redeclare an attribute then I think she's wrong about being able to do it in two steps, and if you can I think she's wrong about having to do it in two steps, but like I said, I'm not certain, so I'll be interested to hear what some other people think. I'm pretty disappointed in the (so far) underwhelming response on xmlschema-dev, but we'll see what happens.

Reply With Quote
  #6  
Old December 21st, 2001, 06:41 PM
JMM JMM is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Feb 2001
Location: USA
Posts: 830 JMM User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 17 m 56 sec
Reputation Power: 8
OK. Jeni was right. To make a long story short: when deriving from a complex type by restriction, any attribute use of the base type that has the same name and target namespace as an attribute child of <restriction> in the derived type is overridden.

As an aside, also pointed out by Jeni, you can't set a default or fixed value for an attribute of or derived from type ID as I did in my example.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreXML Programming > Redeclaring attribute in derived type (XML schema structure)


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway