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

=?UTF-8?Q?Re=3A_=5Bxml=2Ddev=5D_Don=E2=80=99t_create_elements_with_simpl

  • From: yamahito <yamahito@gmail.com>
  • To: "xml-dev@lists.xml.org" <xml-dev@lists.xml.org>
  • Date: Mon, 1 Oct 2018 10:02:57 +0100

=?UTF-8?Q?Re=3A_=5Bxml=2Ddev=5D_Don=E2=80=99t_create_elements_with_simpl
//The need for external knowledge completely contradicts the fundamental axiom of XML

I think that this is the fundamentally false statement.  Unless your data uses some sort of RDF like semantic association, the 'meaning' of your tagging is always external to your mark-up, and even in that case, the RDF semantic layer is 'external knowledge'.

Anyway, 'external knowledge' has always existed in mark-up in a variety of forms: schema, DTDs, documentation, schematron, and good ol' human inference.

On Sat, 29 Sep 2018 at 12:23 Mukul Gandhi <gandhi.mukul@gmail.com> wrote:
On Thu, Sep 27, 2018 at 6:24 PM Costello, Roger L. <costello@m...> wrote:

Here is an element with simple content and an attribute:

<Cost currency="USD">8.95</Cost>

 

The data USD is explicitly labeled. The label indicates that USD is a currency.

What about the data 8.95, is it labeled? No! It is anonymous/unlabeled. Note: Cost is not the label for 8.95; Cost is the label for the whole package.

In my most recent post, I asked, “What is that number (8.95)?” I received excellent responses: 8.95 is a price, 8.95 is an amount, etc. External knowledge was needed to label the data. The need for external knowledge completely contradicts the fundamental axiom of XML.

Therefore, don’t create XML like this:

<Cost currency="USD">8.95</Cost>

instead, create XML like this:

<Cost>


   
<Currency>USD</Currency>
   
<Amount>8.95</Amount>

</Cost>


If you can use a schema, to validate an XML document, I think an XML like <Cost currency="USD">8.95</Cost> can be considered sufficiently labelled (8.95 as well). Following is my 1st attempt to create such a schema document for <Cost currency="USD">8.95</Cost>,

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">

  <xs:element name="Cost">
     <xs:complexType>
       <xs:simpleContent>
          <xs:extension base="Amount">
             <xs:attribute name="currency" type="Currency" use="required"/>
          </xs:extension>
       </xs:simpleContent>
     </xs:complexType>
  </xs:element>
  
  <xs:simpleType name="Amount">
     <xs:restriction base="xs:decimal">
        <xs:minInclusive value="0"/>
     </xs:restriction>
  </xs:simpleType>
  
  <xs:simpleType name="Currency">
     <xs:restriction base="xs:string">
        <xs:enumeration value="USD"/>
        <xs:enumeration value="GBP"/>
     </xs:restriction>
  </xs:simpleType>

</xs:schema>



--
Regards,
Mukul Gandhi


[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.