To expand on the use of name/type versus ref, there are instances where 
name/type is the desired behavior. For example, the following definition (to 
me) makes sense:

<xs:complexType name="ExampleCustomParameter">
  <xs:sequence>
    <xs:element name="MyChannelList"
                type="llrp:listOfUnsignedShort"/>
  </xs:sequence>
  <xs:attributeGroup ref="llrp:paramAttrs"/>
</xs:complexType>

In this case, I want an element named "MyChannelList" to be in my extended 
namespace, but to have its validation rules matched against those of the core 
LTK-XML type listOfUnsignedShort. But I think the name/type model breaks down 
when I want a complex type rather than a simple type. When I want an entire 
complex type (an entire parameter) from the core namespace, I think ref is the 
only way to go -- which seems to require a global element.

For what it's worth...

C

-----Original Message-----
From: Chris Delaney [mailto:[email protected]] 
Sent: Thursday, June 04, 2009 11:32 AM
To: LLRP Toolkit Development List
Subject: Re: [ltk-d] Recommended change to llrp-1x0.xsd

Christian,

This dovetails into the response I was preparing for John. The initial extended 
schema I tried used <xs:element name="LLRPStatus" type="llrp:LLRPStatus"/>, but 
the validator tried to find LLRPStatus within the extended namespace, not llrp 
(LTK-XML). Modifying example2.xsd to use the name/type attributes instead of 
ref yielded the following from XMLStarlet:

$ xml val -e --xsd example2.xsd example2.xml
example2.xml:7: element LLRPStatus: Schemas validity error : Element 
'{http://www.llrp.org/ltk/schema/core/encoding/xml/1.0}LLRPStatus': This 
element is not expected. Expected is ( 
{http://ltk.example.com/ltk/schema/encoding/xml/0.1}LLRPStatus ).
example2.xml - invalid

This is when I found: http://www.w3schools.com/schema/el_element.asp. Under the 
attribute description, it states that ref may include a namespace prefix, while 
type does not make any mention of namespace. What I believe is happening is by 
defining name, the element is now a member of the extended namespace, and thus 
must be prefixed with the extended namespace before the child elements may be 
validated against the core namespace (after the validator follows the type 
attribute). Modifying example2.xml to prefix LLRPStatus as if it were in the 
extended namespace validates properly against the name/type XSD. I tested 
invalid content within LLRPStatus and it correctly identified the error against 
the core LTK-XML namespace.

<example:LLRP_CUSTOM_MESSAGE MessageID="1001"
  xmlns:example="http://ltk.example.com/ltk/schema/encoding/xml/0.1";
  xmlns:llrp="http://www.llrp.org/ltk/schema/core/encoding/xml/1.0";
  xmlns="http://www.llrp.org/ltk/schema/core/encoding/xml/1.0";>
  <example:LLRPStatus>
    <StatusCode>M_Success</StatusCode>
    <ErrorDescription></ErrorDescription>
  </example:LLRPStatus>
</example:LLRP_CUSTOM_MESSAGE>

But I can't believe this is the appropriate way to include a core LLRP 
parameter, by creating an element with the same name in the extended namespace.

Thanks,

C

-----Original Message-----
From: Christian Floerkemeier [mailto:[email protected]] 
Sent: Thursday, June 04, 2009 11:04 AM
To: LLRP Toolkit Development List
Subject: Re: [ltk-d] Recommended change to llrp-1x0.xsd


Chris,

I do not understand why it is necessary to reference llrp:LLRPStatus. 
Why wouldn't defining it the conventional way with name and type the 
conventional way work for you?

e.g.  <xs:element name="LLRPStatus" type="llrp:LLRPStatus" />

instead of  <xs:element ref="llrp:LLRPStatus" />.

Even, if you LLRPStatus was defined under the extension name space, 
referencing a complex type would not be allowed (as mentioned in the 
text you quoted).

Christian


------------------------------------------------------------------------------
OpenSolaris 2009.06 is a cutting edge operating system for enterprises 
looking to deploy the next generation of Solaris that includes the latest 
innovations from Sun and the OpenSource community. Download a copy and 
enjoy capabilities such as Networking, Storage and Virtualization. 
Go to: http://p.sf.net/sfu/opensolaris-get
_______________________________________________
llrp-toolkit-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/llrp-toolkit-devel

Reply via email to