XML, the Perl Way


Overview

The Technology

XML description

XML description

The Code DTD

<!-- The Perl Geek Code DTD -->
<!-- This DTD can be used to generate XML descriptions of 
     various other Geek-type codes.
     Note that this DTD is only indicative and is _not_ used
     by the Perl scripts that come with the Perl Geek Code 
     distribution. For example you can use XHTML basically
     anywhere PCDATA is allowed and you can add attributes
     to subcat that will be picked-up by replace elements -->
<!-- Copyright 2001 - Michel Rodriguez
     All rights reserved.
     This DTD is free software; you can redistribute it and/or
     modify it under the same terms as Perl itself. -->



<!-- A Geek Code -->
<!ELEMENT code      (modifiers, section+)>

<!-- modifiers that apply to all items --> 
<!ELEMENT modifiers (title, modifier+)>
<!-- a modifier has an id, which appears in the code, a short
     form (displayed in the form) and a long form (displayed 
     in the HTML description of the code. Modifiers of type
     simple are just on/off for the item, while modifiers of
     type level can take values based on the various levels
     for each item and... the length of the id! If the id is
     2 characters then they are taken as open/close braces,
     surrounding the level value, otherwise the id is just a
     prefix for the value, hence >++ and (--)  -->
<!ELEMENT modifier  (short, long)>
<!ATTLIST modifier 
          id     ID             #REQUIRED
          type   (simple|level) #REQUIRED>
<!ELEMENT short     (#PCDATA)>
<!ELEMENT long      (#PCDATA)>

<!ELEMENT section   (title, item+)>

<!-- an item might include sub-categories, for exemple language includes
     C, C++, Java... -->
<!ELEMENT item      (title, comments?, subcats?, level+)>
<!ATTLIST item
          id     ID             #REQUIRED>
<!ELEMENT subcats   (subcat+)>
<!ELEMENT subcat    (#PCDATA)>
<!-- the definition of a subcategory: its id, name and additional 
     attributes used to generate the description for the different levels
     of the subcat. god is usually the creator of the language -->
<!ATTLIST subcat
          id     CDATA          #REQUIRED
          god    CDATA          #IMPLIED>
<!-- a level for the category, includes the str (+++, --...) and the 
     associated text. If there are subcategories in the item then replace
     is used to get either the sub cat name  or an attribute -->
     
<!ELEMENT level     (#PCDATA|replace|a|i|b|strong|small|tt)+>
<!ATTLIST level  
          str    CDATA          #REQUIRED>

<!ELEMENT replace   #EMPTY>
<!ATTLIST replace
          val       CDATA       #REQUIRED
          str       CDATA       #REQUIRED>

<!ELEMENT title     (#PCDATA)>
<!ELEMENT comments  (ANY)>


Overview

The Technology

XML description

copyright © 2001 Michel Rodriguez