Home    News    Product    Order    Forum    Feedback    Partner    Profile  © Neatware 2000
 Neatware Snaml
Search
  XML Document
Home  : Last Update: Wed Apr 12 20:09:03 2000

 
Snaml -- XML

 
Snaml Basic
      Introduction
      Syntax
      Control
      Types
      Modules
      Status
Snaml HTML
      HTML
      Structure
      Link
      Objects
      Text
      Font
Snaml CSS
      CSS
      Script
Snaml CGI
      CGI
      Variables
      Output
      Form
      Application
Snaml XML
      XML
      Document
      EBNF
  1. XML Document

    In XML there are six kinds of markup: elements, entity references, comments, processing instructions, CDATA sections, and document type declarations (DTD). XML name is case sensitive

    • Elements

      A Snaml program of XML consists of element commands. They may be start, end, or empty element commands. Commands in between the start element command and the end element command are called content of the element command. Element name is the type of the element. A start element command has a single underscore '_' prefix in front of the element name. It may have a name/value pair list as its attribute list. The end element command has a single underscore '_' postfix attached to the element name. It has no argument. The Empty element command has no content. A double underscore '__' prefix is in front of the element name. It may also have an argument of attribute list.

      The well-formed constraint of XML requires that (i) an end command must match the start command with the same element name; (ii) attribute name can't appear more than once in the list; (iii) attribute values can't contain entity references; and (iv) the character '<' in an attribute value must be replaced by '&lt;'. You may read the XML specification for element validity.

      _print "format='page'"
        _quote "File Description"
      print_
      		

    • References

      There are three kinds of references: character, entity, and parameter-entity reference.

      • Character References

        It refers to a character in the ISO/IEC 10646 character set. For decimal digits its format is '&#N' where N is a decimal number. For hexadecimal digits its format is '&#xM' where M is a hexadecimal number. You may use these digital characters insert Unicode character into an XML document.

        '&#32'  # space character in decimal
        '&#x20' # space character in hexadecimal

      • Entity References

        It refers to the content of a named entity. It has a prefix ampersand '&' and a postfix semicolon ';'. The entities amp, lt, gt, apos, and quot are predefined entities in XML for '&', '<', '>', ''', and '"'. Entity reference can not include a recursion.

        &amp;		'&'
        &lt;		'<'
        &gt;		'>'
        &apos;		'''
        &quot;		'"'
        

      • Parameter-Entity References

        It uses percent sign '%' and semicolon ';' as delimiters. Parameter-entity references may only appear in the DTD.

        %name;

    • Comments

      The empty command __comment specifies its argument as comment. Its XML corresponds are <!-- ... -->. The argument can't contain the double hyphen.

      __comment "NO double hyphen here."
      		

    • Processing Instructions

      The empty command __pi specifies the processing instructions. It allows document contain instructions for applications. Its syntax is '__pi "piTarget piData" where 'piTarget' identifies an application to which it directs the instruction. The target names 'XML', 'xml', and so on are reserved for future standardization.

      __pi "xml 1.0 'hello.dtd'"

    • CDATA Sections

      The empty command __cdata will ignore the markup text in the argument. Therefore, there is no needs for '&lt;' to '<'. CDATA sections can't be nested. The __cdata command completes the function of <![CDATA[ ... ]]> in the XML.

      __cdata "cdata specification here."

    • DTD (Document Type Declarations)

      Through Document Type Declarations (DTD), XML can specify constraints on the logical structure of the markup. DTD must appear before the first element in a document.

      In the following example, the first Processing Instruction __pi declares the xml standard with version 1.0. The standalone value 'no' indicates an external markup declaration. It is also the default value. The value 'yes' indicates no markup external declarations to the document entity.

      In the __doctype command 'greeting' specifies the document name. The system identifier 'hello.dtd' gives a URL of a DTD declaration for the document.

      A typical header for XML document is

      __pi "xml 1.0 standalone='no'"
      __doctype "greeting SYSTEM 'hello.dtd'"

  2. Declarations

    • Element Declaration

      __element empty command consists of an element name and a content specification. Element name specifies the new element. The content specification maybe 'EMPTY', 'ANY', 'children', and 'mixed'. It specifies the possible combination of elements in a content: (i) 'EMPTY' specifies that the new element command is an empty command without content and end element command; (ii) 'ANY' allows any content; (iii) 'children' specifies the regular expression of child elements in its content; (iv) 'mixed' means that the content maybe a character data with '#PCDATA' and children.

      In a regular expression of child, (i) a vertical bar '|' is or; (ii) an asterisk '*' may occur zero or more times; (iii) a plus '+' must occur more than once; (iv) commas ',' specifies that elements must occur in succession; (v) question mark (?) after an element states the element may occur exactly once or nothing; (vi) an element name without special symbol must occur exactly once

      __element "br EMPTY" # empty command
      __element "p (#PCDATA|emph)*" 
      
      # character data and child
      __element "%name.para; %content.para;" # ?
      __element "folder ANY" # any content
      		

    • Attribute Declaration

      __attrlist empty command specifies the attribute list of an element, attribute type constraints, and attribute default values

      __attrlist {elemname (attrname attrtype default)*} 
      		

      where 'elemname' is the related element name; 'attrname' is the attribute name; and 'attrtype' is the attribute type. 'attrtype' maybe a string, a token, or an enumeration: (i) the string type is declared as CDATA. It may be any literal string; (ii) the token type has varing lexical and semantic constraints. 'ID' value must uniquely identify an element. An element can have only one ID. Its default declaration must be '#IMPLIED' or '#REQUIRED'; (iii) 'IDREF' must match the value of an ID attribute; (iv) 'ENTITY' and 'ENTITIES' value(s) must match the name(s). (v) 'NMTOKEN' and 'NMTOKENS' must match Nmtoken(s). Enumeration type declares a list of values that may be 'NOTATION' or 'Nmtoken'.

      The default declaration may have the value '#REQUIRED' in which an attribute must be provided; '#IMPLIED' means no default value; '#FIXED AttrValue' means the default value is AttrValue; The symbol '#FIXED' states that the attribute must always have the default value. It maybe omitted and leave AttrValue as default value. When you declare a default value of an attribute and use an element omitted this attribute, XML will suppose this attribute has the default value. Follows are attribute list example,

      __attrlist {termdef {id ID #REQUIRED} 
                          {name CDATA #IMPLIED}}
      __attrlist {list {type 
                        "(bullets|ordered|glossary)" 
                        "ordered"}}
      __attrlist {form {method CDATA "#FIXED POST"}}
      		

    • Entity Declarations

      It associates a name with other contents. An entity has the form '&entityname;'. Internal entities link a name to a string. XML predefines five internal entities: lt, gt, amp, apos, and quot. External entities link a name to the content of a file. The text file will be parsed as another document and the binary file is not parsed. Parameter entities are declared in the document type declaration (DTD). It has '%' prefix. The parameter-entity references in the document type declaration are replaced by the text.

      __entity {%param_entity 'IGNORE'}
      		

XML Document

Declarations

     
Home  : Last Update: Wed Apr 12 20:09:03 2000
Search
  XML Document
 Neatware Snaml
Home    News    Product    Order    Forum    Feedback    Partner    Profile  © Neatware 2000