Altova Mailing List Archives>Archive Index >comp.text.xml Archive Home >Recent entries >Thread Prev - Looking for very simple document DTD >Thread Next - Re: Looking for very simple document DTD Re: Looking for very simple document DTDTo: NULL Date: 6/1/2004 9:54:00 AM --=-=-= Manuel Collado <m.collado@l...> writes: > I would like to write simple, yet well structured documents with a > really simple XML DTD (or schema). Either Docbook or SDocbook are > overkill for this simple case. Here's the one I've been using for the last 5+ years. XSLT for generating HTML also attached. Using a DTD-directed editor, such as XED [1], makes for very easy authoring. ht [1] http://www.ltg.ed.ac.uk/~ht/xed.html --=-=-= Content-Type: application/octet-stream Content-Disposition: attachment; filename=doc.dtd Content-Description: simple XML document DTD <!--* DTD for my XML documents *--> <!ELEMENT doc (head?,body)> <!ENTITY % bits 'emph|code|name|link'> <!ENTITY % chunks 'p|list|display|note|image|table'> <!ELEMENT head (title,author+,(date|note)*)> <!ELEMENT title (#PCDATA|%bits;)*> <!ELEMENT author (#PCDATA|%bits;)*> <!ELEMENT date (#PCDATA)> <!ELEMENT body (div+)> <!ELEMENT div (title,(div|%chunks;)+)> <!ELEMENT p (#PCDATA|%bits;)*> <!ELEMENT display (#PCDATA|%bits;)*> <!ELEMENT note (#PCDATA|%bits;)*> <!ELEMENT list ((note|item)+)> <!ATTLIST list type (normal|enum|defn|naked|tdefn) 'normal' term-width CDATA "30pt" term-align (left|center|right|justify|char) "right"> <!ELEMENT emph (#PCDATA)> <!ATTLIST emph color CDATA #IMPLIED> <!ELEMENT code (#PCDATA|%bits;)*> <!ELEMENT name (#PCDATA)> <!ELEMENT item (#PCDATA|%chunks;|%bits;)*> <!ATTLIST item term CDATA #IMPLIED> <!ELEMENT link (#PCDATA|%bits;)*> <!ATTLIST link href CDATA #IMPLIED name CDATA #IMPLIED> <!ELEMENT image (#PCDATA)> <!ATTLIST image source CDATA #REQUIRED> <!ENTITY lt '&#60;'> <!-- allow for table under control of withTables entity. Either use -i withTables when invoking doxt or nsgmlx to enable, or put <!ENTITY % withTables 'INCLUDE'> in your internal subset --> <!ENTITY % withTables 'IGNORE'> <![%withTables;[ <!ENTITY % tableDTD SYSTEM 'html-table.dtd'> %tableDTD; ]]> --=-=-= Content-Type: text/xml Content-Disposition: attachment; filename=doc.xsl Content-Description: stylesheet for simple XML document DTD <?xml version='1.0'?> <!DOCTYPE xsl:stylesheet [ <!ENTITY nbsp " "> ]> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:output method="html"/> <!-- The real stylesheet starts here --> <xsl:template match="/"> <HTML> <HEAD> <META HTTP-EQUIV="Content-type" CONTENT="text/html; charset=UTF-8"/> <TITLE> <xsl:for-each select="doc/head/title"> <xsl:value-of select="."/> </xsl:for-each> </TITLE> <xsl:if test="doc/@style"> <LINK href="http://www.w3.org/StyleSheets/{doc/@style}.css" rel="stylesheet" type="text/css"/> </xsl:if> <STYLE type="text/css"> PRE.code {font-family: monospace} PRE {MARGIN-LEFT: 0em} OL OL {list-style-type: lower-alpha} </STYLE> </HEAD> <BODY STYLE="font-family: times"> <xsl:apply-templates/> </BODY> </HTML> </xsl:template> <xsl:template match="head"> <DIV STYLE="text-align: center"> <xsl:apply-templates/> </DIV> </xsl:template> <xsl:template match="author|date"> <DIV> <xsl:apply-templates/> </DIV> </xsl:template> <xsl:template match="title"> <P> <xsl:number format="1.1. " level="multiple" count="div"/>   <xsl:apply-templates/> </P> </xsl:template> <xsl:template match="head/title"> <H1> <xsl:apply-templates/> </H1> </xsl:template> <xsl:template match="div/title"> <H2> <xsl:number format="1.1. " level="multiple" count="div"/>   <xsl:apply-templates/> </H2> </xsl:template> <xsl:template match="div//div/title"> <H4> <xsl:number format="1.1. " level="multiple" count="div"/>   <xsl:apply-templates/> </H4> </xsl:template> <xsl:template match="p"> <P> <xsl:apply-templates/> </P> </xsl:template> <xsl:template match="image"> <IMG border="0" alt="{@textGloss}" src="{@source}"/> </xsl:template> <xsl:template match="note"> <P> <CENTER><SMALL><I><xsl:apply-templates/></I></SMALL></CENTER> </P> </xsl:template> <xsl:template match="emph"> <I> <xsl:apply-templates/> </I> </xsl:template> <xsl:template match="emph[@color]"> <SPAN style="color: {@color}"> <xsl:apply-templates/> </SPAN> </xsl:template> <xsl:template match="name"> <B> <xsl:apply-templates/> </B> </xsl:template> <xsl:template match="link[@href]"> <A> <xsl:attribute name="href"> <xsl:value-of select="@href"/> </xsl:attribute> <xsl:apply-templates/> </A> </xsl:template> <xsl:template match="link[@name]"> <A> <xsl:attribute name="name"> <xsl:value-of select="@name"/> </xsl:attribute> <xsl:apply-templates/> </A> </xsl:template> <xsl:template match="code"> <CODE> <xsl:apply-templates/> </CODE> </xsl:template> <xsl:template match="display/code"> <PRE class="code"> <xsl:apply-templates/> </PRE> </xsl:template> <xsl:template match="display"> <BLOCKQUOTE> <xsl:apply-templates/> </BLOCKQUOTE> </xsl:template> <xsl:template match="list[@type="defn"]"> <DL> <xsl:apply-templates/> </DL> </xsl:template> <xsl:template match="list[@type="defn"]/item"> <DT><B><xsl:value-of select="@term"/></B></DT> <DD><xsl:apply-templates/></DD> </xsl:template> <xsl:template match="list[@type="normal"]"> <UL> <xsl:apply-templates/> </UL> </xsl:template> <xsl:template match="list[@type="enum"]"> <OL> <xsl:apply-templates/> </OL> </xsl:template> <xsl:template match="list[@type="normal" or @type="enum"]/item"> <LI><xsl:apply-templates/></LI> </xsl:template> <xsl:template match="list[@type='naked']"> <P><xsl:apply-templates/></P> </xsl:template> <xsl:template match="list[@type='naked']/item"> <BR/> <xsl:apply-templates/> </xsl:template> <xsl:template match="list[@type='naked']/item[1]"> <xsl:apply-templates/> </xsl:template> <!-- Tables just copy over the entire subtree, as is except that the children of TD, TH and CAPTION are possibly handled by other templates in this stylesheet --> <xsl:template match="table|caption|thead|tfoot|tbody|colgroup|col|tr|th|td|@*"> <xsl:copy> <xsl:apply-templates select="* | @* | text()"/> </xsl:copy> </xsl:template> </xsl:stylesheet> --=-=-= -- Henry S. Thompson, HCRC Language Technology Group, University of Edinburgh Half-time member of W3C Team 2 Buccleuch Place, Edinburgh EH8 9LW, SCOTLAND -- (44) 131 650-4440 Fax: (44) 131 650-4587, e-mail: ht@i... URL: http://www.ltg.ed.ac.uk/~ht/ [mail really from me _always_ has this .sig -- mail without it is forged spam] --=-=-=-- | ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
