Commit 4d926ac5 authored by O'Reilly Media, Inc.'s avatar O'Reilly Media, Inc.
Browse files

Initial commit

parents
Loading
Loading
Loading
Loading

README.md

0 → 100644
+15 −0
Changes for README.md: 15 added lines, 0 removed lines.
Original line number Diff line number Diff line
## Example files for the title:  
  
# RELAX NG, by Eric van der Vlist
  
[![RELAX NG, by Eric van der Vlist](http://akamaicovers.oreilly.com/images/9780596004217/cat.gif)](https://www.safaribooksonline.com/library/view/title/0596004214//)
  
The following applies to example files from material published by O’Reilly Media, Inc. Content from other publishers may include different rules of usage. Please refer to any additional usage rights explained in the actual example files or refer to the publisher’s website.
  
O'Reilly books are here to help you get your job done. In general, you may use the code in O'Reilly books in your programs and documentation. You do not need to contact us for permission unless you're reproducing a significant portion of the code. For example, writing a program that uses several chunks of code from our books does not require permission. Answering a question by citing our books and quoting example code does not require permission. On the other hand, selling or distributing a CD-ROM of examples from O'Reilly books does require permission. Incorporating a significant amount of example code from our books into your product's documentation does require permission.
  
We appreciate, but do not require, attribution. An attribution usually includes the title, author, publisher, and ISBN.
  
If you think your use of code examples falls outside fair use or the permission given here, feel free to contact us at <permissions@oreilly.com>.
  
Please note that the examples are not production code and have not been carefully testing. They are provided "as-is" and come with no warranty of any kind.

example_code/appa.txt

0 → 100644
+66 −0
Changes for example_code/appa.txt: 66 added lines, 0 removed lines.
Original line number Diff line number Diff line
appendix: DSDL
==================
 <sch:schema xmlns:sch="http://www.ascc.net/xml/schematron">
  <sch:title>Schematron Schema for library</sch:title>
  <sch:pattern>
   <sch:rule context="/">
    <sch:assert test="library">The document element should be "library".</sch:assert>
   </sch:rule>
   <sch:rule context="/library">
    <sch:assert test="book">There should be at least a book!</sch:assert>
    <sch:assert test="not(@*)">No attribute for library, please!</sch:assert>
   </sch:rule>
   <sch:rule context="/library/book">
    <sch:report test="following-sibling::book/@id=@id">
      Duplicated ID for this book.</sch:report>
    <sch:assert test="@id=concat('_', isbn)">
      The id should be derived from the ISBN.</sch:assert>
   </sch:rule>
   <sch:rule context="/library/*">
    <sch:assert test="self::book or self::author or self::character">
      This element shouldn't be here...</sch:assert>
   </sch:rule>
  </sch:pattern>
 </sch:schema>
    
    
====================================
 <sch:assert test="@id=concat('_', isbn)">The id should be derived
from the ISBN.</sch:assert>
    
    
====================================
 <rules xmlns="http://www.thaiopensource.com/validate/nrl">
  <namespace ns="http://schemas.xmlsoap.org/soap/envelope/">
    <validate schema="soap-envelope.xsd"/>
  </namespace>
  <namespace ns="http://www.w3.org/1999/xhtml">
    <validate schema="xhtml.rng"/>
  </namespace>
 </rules>
    
    
====================================
 <crvx xmlns="http://dret.net/xmlns/crvx10">
  <restrict structure="ename aname pitarget" charrep="\p{IsBasicLatin}"/>
  <restrict structure="ename aname" charrep="[^0-9]"/>
 </crvx>
    
    
====================================
<?xml version="1.0" encoding="utf-8"?>Declarative Document Architectures

 <framework>
  <rule>
   <instance>
    <transform transformation="normalize.xslt"/>
   </instance>
   <assert>
    <isValid schema="schema.rng"/>
    <isValid schema="schema.sch"/>
   </assert>
  </rule>
 </framework>
    
    
==================
 No newline at end of file

example_code/appb.txt

0 → 100644
+24 −0
Changes for example_code/appb.txt: 24 added lines, 0 removed lines.
Original line number Diff line number Diff line
appendix: The GNU Free Documentation License
==================
Copyright (C) 2000,2001,2002 Free Software Foundation, Inc.
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
    
    
====================================
Copyright (c)  YEAR  YOUR NAME.
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.2
or any later version published by the Free Software Foundation;
with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
A copy of the license is included in the section entitled "GNU
Free Documentation License".
    
    
====================================
with the Invariant Sections being LIST THEIR TITLES, with the
Front-Cover Texts being LIST, and with the Back-Cover Texts being LIST.
    
    
==================
 No newline at end of file

example_code/ch03.txt

0 → 100644
+278 −0
Changes for example_code/ch03.txt: 278 added lines, 0 removed lines.
Original line number Diff line number Diff line
chapter: First Schema
==================
Example: Sample instance document

<?xml version="1.0"?>
 <library>
  <book id="b0836217462" available="true">
   <isbn>0836217462</isbn>
   <title xml:lang="en">Being a Dog Is a Full-Time Job</title>
   <author id="CMS">
    <name>Charles M Schulz</name>
    <born>1922-11-26</born>
    <died>2000-02-12</died>
   </author>
   <character id="PP">
    <name>Peppermint Patty</name>
    <born>1966-08-22</born>
    <qualification>bold, brash and tomboyish</qualification>
    </character>
   <character id="Snoopy">
    <name>Snoopy</name>
    <born>1950-10-04</born>
    <qualification>extroverted beagle</qualification>
   </character>
   <character id="Schroeder">
    <name>Schroeder</name>
    <born>1951-05-30</born>
    <qualification>brought classical music to the Peanuts strip</qualification>
   </character>
   <character id="Lucy">
    <name>Lucy</name>
    <born>1952-03-03</born>
    <qualification>bossy, crabby and selfish</qualification>
   </character>
  </book>
 </library>
    
    
====================================
 <text/>
    
    
====================================
 <attribute name="id">
  <text/>
 </attribute>
    
    
====================================
  <attribute name="id"/>
    
    
====================================
 <element name="name">
  <text/>
 </element>
    
    
====================================
 <name/>
    
    
====================================
 <name>Charles M Schulz</name>
    
    
====================================
 <element name="title">
  <attribute name="xml:lang"/>
  <text/>
 </element>
    
    
====================================
 <element name="title">
  <attribute name="xml:lang"/>
   <text/>
 </element>
    
    
====================================
 <element name="title">
  <text/>
  <attribute name="xml:lang"/>
 </element>
    
    
====================================
 <element name="author">
  <attribute name="id"/>
  <element name="name">
   <text/>
  </element>
  <element name="born">
   <text/>
  </element>
  <element name="died">
   <text/>
  </element>
 </element>
    
    
====================================
 <optional>
  <element name="born">
   <text/>
  </element>
 </optional>
 <optional>
  <element name="died">
   <text/>
  </element>
 </optional>
    
    
====================================
 <optional>
  <element name="born">
   <text/>
  </element>
  <element name="died">
   <text/>
  </element>
 </optional>
    
    
====================================
 <optional>
  <element name="born">
   <text/>
  </element>
  <optional>
   <element name="died">
    <text/>
   </element>
  </optional>
 </optional>
    
    
====================================
<oneOrMore>
  <element name="author">
    <attribute name="id"/>
    <element name="name">
      <text/>
    </element>
    <element name="born">
      <text/>
    </element>
    <optional>
      <element name="died">
        <text/>
      </element>
    </optional>
  </element>
</oneOrMore>
    
    
====================================
<zeroOrMore>
 <element name="character">
  <attribute name="id"/>
  <element name="name">
   <text/>
  </element>
  <optional>
   <element name="born">
    <text/>
   </element>
  </optional>
  <element name="qualification">
   <text/>
  </element>
 </element>
</zeroOrMore>
    
    
====================================
 <?xml version = '1.0' encoding = 'utf-8' ?>
 <element xmlns="http://relaxng.org/ns/structure/1.0" name="library">
  <oneOrMore>
   <element name="book">
    <attribute name="id"/>
    <attribute name="available"/>
    <element name="isbn">
     <text/>
    </element>
    <element name="title">
     <attribute name="xml:lang"/>
     <text/>
    </element>
    <oneOrMore>
     <element name="author">
      <attribute name="id"/>
      <element name="name">
       <text/>
      </element>
      <optional>
       <element name="born">
        <text/>
       </element>
      </optional>
      <optional>
       <element name="died">
        <text/>
       </element>
      </optional>
     </element>
    </oneOrMore>
    <zeroOrMore>
     <element name="character">
      <attribute name="id"/>
      <element name="name">
       <text/>
      </element>
      <optional>
       <element name="born">
        <text/>
       </element>
      </optional>
      <element name="qualification">
       <text/>
      </element>
     </element>
    </zeroOrMore>
   </element>
  </oneOrMore>
 </element>
    
    
====================================
<!-- 1 -->
<element name="character">
 <attribute name="id"/>
 <element name="name">
  <text/>
 </element>
 <optional>
  <element name="born">
   <text/>
  </element>
 </optional>
 <element name="qualification">
  <text/>
 </element>
</element>
<!-- 2 -->
<element name="character">
  .../...
</element>
<!-- 3 -->
<optional>
 <element name="character">
 .../...
  </element>
 </element>
</optional>
<!-- 4 -->
<optional>
 <element name="character">
 .../...
 </element>
</optional>
<!-- 5 -->
<optional>
 <element name="character">
 .../...
 </element>
</optional>
<!-- 6 -->
<optional>
 <element name="character">
 .../...
 </element>
</optional>
    
    
==================
 No newline at end of file

example_code/ch04.txt

0 → 100644
+120 −0
Changes for example_code/ch04.txt: 120 added lines, 0 removed lines.
Original line number Diff line number Diff line
chapter: Introducing the Compact Syntax
==================
text
    
    
====================================
 attribute id { text }
    
    
====================================
<attribute name="id"/>
    
    
====================================
 attribute id { text }
    
    
====================================
attribute id { }
    
    
====================================
attribute text { text } 
attribute attribute { text }
    
    
====================================
element name { text }
    
    
====================================
element title { attribute xml:lang { text }, text }
    
    
====================================
element title {attribute xml:lang{ text }, text}
    
    
====================================
element author { attribute id { text }, element name { text }, element born 
    { text }, element died { text } }
    
    
====================================
attribute id { text }?
    
    
====================================
element author { attribute id { text }, element name { text }, element born 
    { text }?, element died { text }? }
    
    
====================================
element author {( attribute id { text }, element name { text }, element born
    { text }?, element died { text }? )}
    
    
====================================
element author { (attribute id { text }), (element name { text }),
    (element born { text })?, (element died { text }?) }
    
    
====================================
<optional> <element name="born"> <text/> </element>
    <element name="died"> <text/> </element> </optional>
    
    
====================================
(element born { text }, element died { text })?
    
    
====================================
<optional> <element name="born"> <text/>
    </element> <optional> <element name="died"> <text/> </element>
    </optional> </optional>
    
    
====================================
(element born { text }, element died { text }? )?
    
    
====================================
element author { attribute id { text }, element name { text }, element born
    { text }?, element died { text }? }+
    
    
====================================
element character { attribute id { text }, element name { text }, element born 
    { text }?, element qualification { text } }*
    
    
====================================
Example: Compact syntax of full RELAX NG schema

element library {
   element book {
     attribute id { text },
     attribute available { text },
     element isbn { text },
     element title {
       attribute xml:lang { text },
       text
     },
     element author {
       attribute id { text },
       element name { text },
       element born { text }?,
       element died { text }?
     }+,
     element character {
       attribute id { text },
       element name { text },
       element born { text }?,
       element qualification { text }
     }*
   }+
}
    
    
==================
 No newline at end of file
Loading