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

RE: XML Schema/attributeGroup and namespaces

  • From: "Xia Li" <xli@g...>
  • To: "Stefan Krause" <stf@s...>, <xml-dev@l...>
  • Date: Tue, 27 May 2008 13:16:08 -0700

RE:  XML Schema/attributeGroup and namespaces
Hi,

	The locally declared attribute such as "attr3" by default is
unqualified. You can't prefix it with the prefix associated with the
target namespace of the schema "bar.xsd". 
	To make it qualified, you can explicitly set the attribute
"attributeFormDefault" on the "schema" element to the value "qualified"
so that all locally declared attributes including the "attr3" would
belong to the target namespace "http://bar".

Lisa


-----Original Message-----
From: Stefan Krause [mailto:stf@s...] 
Sent: Tuesday, May 27, 2008 12:43 PM
To: xml-dev@l...
Subject:  XML Schema/attributeGroup and namespaces

Hello,

I run into some difficulties while importing a xs:attributeGroups with
the right namespace. Look at this document:

== foo.xml ==
<?xml version="1.0" encoding="UTF-8"?>
<root
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:noNamespaceSchemaLocation="foo.xsd"
	xmlns:bar="http://bar">
	
	<element attr1="1" bar:attr2="2" bar:attr3="3"/>
</root>

The element has three attributes, attr1 is in the noNamespace, the
others are in the "http://bar"-namespace.

Here are the schemas:

== foo.xsd ==
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema
	xmlns:xs="http://www.w3.org/2001/XMLSchema"
	elementFormDefault="qualified"
	xmlns:bar="http://bar">
	<xs:import namespace="http://bar" schemaLocation="bar.xsd"/>
	<xs:element name="root">
		<xs:complexType>
			<xs:sequence>
				<xs:element ref="element"/>
			</xs:sequence>
		</xs:complexType>
	</xs:element>
	<xs:element name="element">
		<xs:complexType>
			<xs:attribute name="attr1"/>
			<xs:attribute ref="bar:attr2"/>
			<xs:attributeGroup ref="bar:group"/>
		</xs:complexType>
	</xs:element>
</xs:schema>

== bar.xsd ==
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema
	xmlns:xs="http://www.w3.org/2001/XMLSchema"
	elementFormDefault="qualified"
	targetNamespace="http://bar"
	xmlns:bar="http://bar">
	<xs:attribute name="attr2"/>
	<xs:attributeGroup name="group">
		<xs:attribute name="attr3"/>
		<xs:attribute name="attr4"/>
	</xs:attributeGroup>
</xs:schema>

While validating, attr1 and attr2 are OK, but attr3 raises an error. On
the other hand, putting attr3 in noNamespace (writing attr3 without the
prefix), also attr3 is OK.

I really need a straightforward way to import xs:attributeGroups from
external schemas into a separate namespace, so how can I do this?

Thanks for your advices,

Stefan

_______________________________________________________________________

XML-DEV is a publicly archived, unmoderated list hosted by OASIS
to support XML implementation and development. To minimize
spam in the archives, you must subscribe before posting.

[Un]Subscribe/change address: http://www.oasis-open.org/mlmanage/
Or unsubscribe: xml-dev-unsubscribe@l...
subscribe: xml-dev-subscribe@l...
List archive: http://lists.xml.org/archives/xml-dev/
List Guidelines: http://www.oasis-open.org/maillists/guidelines.php



[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]


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.