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

Re: Dilemma: dot notation or attribute


dot notation attribute id
Autumn Cuellar <a.cuellar@a...> wrote:

| I want to be able to import one document with the root element <model> 
| into another document with the same root element and then access element 
| content in the imported "model". 

Is there anything wrong with referencing content in the document you want
to "import"?  

| The dot notation method:
| <model>
|    <import_model name="example"
| 	uri="http://www.example.com/sample_model.xml" />
| 
|    <variable name="A" units="example.meter_per_cm2"/>
| </model>
| 
| The above method effectively aliases "example" to the sample model uri, 
| and then the variable can reference units defined in another model by 
| listing the model nickname and the units separated by a dot.
| 
| The attribute method:
| <model>
|    <import_model name="example"
| 	uri="http://www.example.com/sample_model.xml" />
| 
|    <variable name="A" units="meter_per_cm2" units_model="example" />
| <model>
| 
| The attribute method is similar, however, the imported model is 
| referenced via a specific attribute.
| 
| Neither method is exactly XML-happy.

The second method is fine.  A slight improvement would be to take
advantage of the validation features of the ID/IDREF mechanism.  In your
internal subset (or in the full DTD):

   <!ATTLIST  import_model
              alias  ID      #REQUIRED
              uri    CDATA   #REQUIRED
              >
   <!ATTLIST  variable
              name    NAME    #REQUIRED
              units   CDATA   #RQEUIRED
              unitref IDREF   #IMPLIED
              >

And now, in

  <model>
    <import_model alias="example"  
                  uri="http://www.example.com/sample_model.xml" />
 
    <variable name="A" units="meter_per_cm2" unitref="example" />
  </model>
 
the unitref attribute is known to refer to the <import_model/> element
with the alias "example".  As far as youir application is concerned, it
can figure out the provenance of the units of the <variable> by following
the reference.

| You expect the attribute value to be a literal value with no hidden 
| meaning for a processor to detect, as would be necessary with the 
| dot notation.  

Correct.

| However, there have been instances where groups give certain meaning 
| to parts of an attribute value.

Sadly so.

| And the attribute method bothers me because the "units_model" attribute 
| is qualifying another attribute instead of the element it's placed on.

It isn't the best design, but controlling interpretation of one attribute
by means of another can be an effective descriptive technique at times.


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.