[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: Duplicate element decl in the same scope


xs unique
well couldn't you do



<xs:complexType name="blah">
 		<xs:sequence>
<xs:element name="element" type="one:footype"  minOccurs="1" maxOccurs="1"/>
<xs:element ref="one:element" minOccurs="0"
 maxOccurs="unbounded"/></xs:sequence>
 			</xs:complexType>
 <xs:complexType name="footype">
...
</xs:complexType>		
<xs:element name="element">
...
</xs:element>
 	

to specify particular constraints on different 'element' elements, and still use
the unique to constrain the attributes in their final state, which i believe
should work if we elementFormDefault is qualified because all the various
'element' elements will be in the same namespace, thus satisfying the
xs:selector xpath. 
-- 
Bryan Rasmussen


Citat Robert Soesemann <rsoesemann@s...>:

> Thanks a lot for this example. But it won't work as I need to put
> additional constraints on the XSD. There might be <element type="foo">
> that must appear inside the XML and <element type="bar"> that is
> optional. 
> I guess there is no way to express that with your solution.
> 
> Robert
> 
> -----Original Message-----
> From: Bryan Rasmussen [mailto:bry@i...] 
> Sent: Dienstag, 11. Januar 2005 15:00
> To: xml-dev@l...
> Subject: RE:  Duplicate element decl in the same scope
> 
> 
> I forgot to cc xml-dev, to make sure it gets to you (since I've been
> having some problems with my web-based mail i will send this there now)
> 
> the following fragment 
> <xs:element name="root" type="one:blah">
> 	<xs:unique name="element1">
> 		<xs:selector xpath="one:element"></xs:selector>
> 		<xs:field xpath="@name"></xs:field>
> 	</xs:unique>
> 	</xs:element>
> 	<xs:complexType name="blah">
> 		<xs:sequence>
> 			<xs:element name="element" minOccurs="0"
> maxOccurs="unbounded">
> 				<xs:complexType>
> 					<xs:attribute name="name"
> type="xs:string"/>
> 				</xs:complexType>
> 			</xs:element>
> 					</xs:sequence>
> 	</xs:complexType>
> 
> without a specific type for the name attribute does the uniqueness
> constraint. 
> -- 
> Bryan Rasmussen
> 
> 
> Citat Robert Soesemann <rsoesemann@s...>:
> 
> > Could you please give a short example. I don't understand exactely how
> 
> > this could solve my problem.
> > 
> > -----Original Message-----
> > From: Bryan Rasmussen [mailto:bry@i...]
> > Sent: Dienstag, 11. Januar 2005 14:13
> > To: Robert Soesemann
> > Cc: xml-dev@l...
> > Subject: Re:  Duplicate element decl in the same scope
> > 
> > 
> > How about the following hack, you specify a pattern for what the 
> > attributes have to have as a possible value, then you use xsd:unique 
> > to make sure that an attribute value does not repeat.
> > --
> > Bryan Rasmussen
> > 
> > 
> > Citat Robert Soesemann <rsoesemann@s...>:
> > 
> > > Hello,
> > > 
> > > For the XML format of my application I need to store semantics 
> > > inside
> > > attribute value:
> > > 
> > > So instead of (A) I need (B):
> > > (A)
> > > <root>
> > > 	<ELEM1/>
> > > 	<ELEM2/>
> > > </root>
> > > (B)
> > > <root>
> > > 	<top name="ELEM1"/>
> > > 	<top name="ELEM2"/>
> > > </root>
> > > 
> > > The problem I face is how to validate this with XMLSchema as e.g. 
> > > two
> > > <top> elements are different only regarding an attribute value. You 
> > > find a simple example of an XSD snippet where I test the above XML 
> > > with xs:all.
> > > 
> > > <xs:element name="root">
> > >   <xs:complexType>
> > >    <xs:all>
> > >     <xs:element name="element">
> > >      <xs:complexType>
> > >       <xs:attribute name="name" type="xs:string" fixed="ELEM1"/>
> > >      </xs:complexType>
> > >     </xs:element>
> > >     <xs:element name="element">
> > >      <xs:complexType>
> > >       <xs:attribute name="name" type="xs:string" fixed="ELEM2"/>
> > >      </xs:complexType>
> > >     </xs:element>
> > >    </xs:all>
> > >   </xs:complexType>
> > >  </xs:element>
> > > 
> > > When I validate this XSD *itself* I get the following error inside 
> > > my
> > > XML Suite: "Duplicate element decl in the same scope: element
> > > 'element' and 'element' violate the Unique Particle Attribution
> rule"
> > > 
> > > Any solutions. Is this not solveable in XSD?
> > > 
> > > Robert
> > > 
> > > -----------------------------------------------------------------
> > > The xml-dev list is sponsored by XML.org <http://www.xml.org>, an
> > > initiative of OASIS <http://www.oasis-open.org>
> > > 
> > > The list archives are at http://lists.xml.org/archives/xml-dev/
> > > 
> > > To subscribe or unsubscribe from this list use the subscription
> > > manager: <http://www.oasis-open.org/mlmanage/index.php>
> > > 
> > > 
> > 
> > 
> > 
> 
> 
> 
> -----------------------------------------------------------------
> The xml-dev list is sponsored by XML.org <http://www.xml.org>, an
> initiative of OASIS <http://www.oasis-open.org>
> 
> The list archives are at http://lists.xml.org/archives/xml-dev/
> 
> To subscribe or unsubscribe from this list use the subscription
> manager: <http://www.oasis-open.org/mlmanage/index.php>
> 
> 
> -----------------------------------------------------------------
> The xml-dev list is sponsored by XML.org <http://www.xml.org>, an
> initiative of OASIS <http://www.oasis-open.org>
> 
> The list archives are at http://lists.xml.org/archives/xml-dev/
> 
> To subscribe or unsubscribe from this list use the subscription
> manager: <http://www.oasis-open.org/mlmanage/index.php>
> 
> 



PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.