OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

 


 

   Re: [xml-dev] Dilemma: dot notation or attribute

[ Lists Home | Date Index | Thread Index ]

Autumn Cuellar <a.cuellar@auckland.ac.nz> 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.





 

News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 2001 XML.org. This site is hosted by OASIS