Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


advertisement
 

XML Reference : Page 2

In this section, we provide additional resources for XML, including links to XML parsers and XML tool vendors. We also explain the XML-related technologies, from DTD to XQL, provide a list of links to specifications, drafts, and additional information about these related technologies.


advertisement

Element and Attribute Rules

The first table contains the basic guidelines for creating element rules in an XML DTD.

The second contains attribute value types.



The third contains attribute default options.

Element Rules:

Symbol

Meaning

Example

#PCDATA

Contains parsed character data, or text.

<POW(#PCDATA)>

The POW element contains textual data.

#PCDATA, element-name

Contains text and another element. #PCDATA is always listed first in a rule.

<POW(#PCDTATA, NAME)>

The POW element must contain both text and the NAME element.

,
(comma)

Use in this order

<POW (NAME, RANK, SERIAL)>

The POW element must contain the NAME element, followed by the RANK element, followed by the SERIAL element.

|
(bar)

Use either or

< POW(NAME | RANK | SERIAL)>

The POW element must contain either the NAME element, or the RANK element, or the SERIAL element.

name
(by itself)

Use one time only

<POW (NAME)>

The POW element must contain the NAME element, used exactly one time.

name?

Use either once or not at all

<POW(NAME, RANK?, SERIAL?)>

The POW element must contain the NAME element used exactly oncee, followed by one or none RANK elements, and one or none SERIAL elements.

name+

Use either once or many times

<POW(NAME+, RANK?, SERIAL)>

The POW element must contain at least one but maybe more NAME elements, followed by one or none RANK elements, and exactly one SERIAL elements.

name*

Use once, use many times, or don't use it at all.

<POW(NAME*, RANK?, SERIAL)>

The POW element must contain at one, many, or none NAME elements, followed by one or none RANK elements, and exactly one SERIAL elements.

( )

Indicated groups, may be nested.

<POW(#PCDATA | NAME)*>

The POW element contains one more use uses of either or both text and the NAME element.

<POW((NAME*, RANK?, SERIAL)* | COMMENT)>

The POW element must contain many instances of the group that contains one, many, or none NAME elements, followed by one or none RANK elements, and exactly one SERIAL elements. OR, it may contain one COMMENT element.

<POW(NAME | RANK)+>

The POW element must contain a NAME or RANK element. The NAME or RANK option may appear once or may be repeated many times.

Attribute Values:

Type

Meaning

Example

CDATA

Character data, text.

<ATTLIST COMMENT category CDATA #REQUIRED>

The COMMENT element has an attribute named category. This attribute contains letters, numbers, or punctuation symbols.

NMTOKEN

Name token, text with some restrictions. The value contains number and letter. However, it cannot begin with the letters "xml" and the only symbols it can contain are _, -, ., and :..

<ATTLIST COMMENT category NMTOKEN #REQUIRED>

The COMMENT element has an attribute named category. This attribute contains a name token.

(value-1 | value-2 | value-3)
value list

A value list provides a set of acceptable options for the attribute to contain. In general, you should always include "other" as one of the options.

<ATTLIST COMMENT category (red | green | blue | other) "other">

The COMMENT element has an attribute named category. The category can be "red," "green," "blue," or "other." The default value is "other."

ID

The keyword ID means that this attribute has an ID value that idenifies this particular element.

<ATTLIST COMMENT category ID #IMPLIED>

The COMMENT element has an attribute named category. The category will contain an ID value. ID and IDREF work together to create cross-references.

IDREF

The keyword IDREF means that this attribute has an ID reference value that points to another instance's ID value.

<ATTLIST COMMENT category IDREF #IMPLIED>

The COMMENT element has an attribute named category. The category will contain an IDREF value. ID and IDREF work together to let you do cross-reference elements.

ENTITY

The keyword ENTITY means that this attribute's value is an entity. An entity is a value that has been defined elsewhere in the DTD to have a particular meaning.

<ATTLIST COMMENT category ENTITY #IMPLIED>

The COMMENT element has an attribute named category. The category will contain an entity name rather than text.

NOTATION

The keyword NOTATION means that this attribute's value is a notation. A notation is a description of how information should be processed. You could set up a notation that allows only numbers to be used for the value, for example.

<ATTLIST COMMENT category NOTATION #IMPLIED>

The COMMENT element has an attribute named category. The category attribute will contain a notation name.

Attribute Default Options:

Type Meaning Example
#REQUIRED
The attribute must always be included when the element is used. <ATTLIST COMMENT category CDATA #REQUIRED>

The COMMENT element has an attribute named category. This attribute contains letters, numbers, or punctuation symbols. The attribute must always be used with the element. If you omit the attribute, the parser will give you an error message.
#IMPLIED The attribute is optional. If you see the keyword #IMPLIED, you know that this attribute will be ignored unless it is included in the element tag. It won't take on any default values. <ATTLIST COMMENT category CDATA #IMPLIED>

The COMMENT element has an attribute named category. You may use the attribute or omit the attribute, as the instance requires.
#FIXED The attribute is optional, but if it is used, it must always have a certain value. If you see the keyword #FIXED, you know that this attribute will always have the specified value when it is entered.

<ATTLIST COMMENT confirm #FIXED "yes">

The COMMENT element has an attribute named confirm. If it is used, its value will be "yes." If it is not used, it will not have a value.
"value" A value in quotes is the default value of this attribute. If you don't enter the attribute in the element tag, the processor will assume the attribute has this default value. <ATTLIST COMMENT category (red|green|blue|other) "other">

The COMMENT element has an attribute named category. If you don't use the attribute in the element tag, the attribute will automatically receive the value "other."


Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date