[diary-sys:00121] DTD for diary


[検索] [スレッド順] [日付順]

スレッド順: ( ←前へ | →次へ | 目次 ) || 日付順: ( ←前へ | →次へ | 目次 )


tom です。

現実逃避に DTD らしきものを書いてみました。
またまだ未完成ですが、プロトタイプということで。
どんどん叩いてあげて下さい。
#先頭のコメント文は、HTML 4.0 からのパクリです ^^;)

ついでにサンプル xml と diary.xsl もつけておきます。

------------------------------------------------
% cat dml.dtd
<!--
    This is DML(DiaryMarkupLanguage) 1.0 DTD, which excludes the
presentation
    attributes and element that TDS expect to phase out as
    support for style sheets matures. Diary Authors should use this DTD
    when possible.

        Draft: $Date$

 Author:
     TANAKA Tomonari <tom@morito.mgmt.waseda.ac.jp>

    Further information about DML 1.0 is ... not available now.
    maybe

        http://www.morito.mgmt.waseda.ac.jp/~tom/TomSoft/TsDiary/DML/

    but now underconstruction.

-->
<!--
    Typical usage:

    <?xml version="1.0" encoding="UTF-8"?>
    <?xml-stylesheet type="text/xsl" href="diary.xsl"?>
    <!DOCTYPE DML SYSTEM
"http://www.morito.mgmt.waseda.ac.jp/~tom/TomSoft/TsDiary/~tom/TomSoft/TsDia
ry/DML/dml.dtd">
    <diary>
    <rdf:RDF
 xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
 xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
 xmlns:dc="http://purl.org/dc/elements/1.0/"
    >
    <rdf:Description>
     <dc:Creator>your name</dc:Creator>
     <dc:Creator.Email>your email address</dc:Creator.Email>
     <dc:Title>your diary title</dc:Title>
    </rdf:Description>
    </rdf:RDF>

    <daily>
        <topic>
     <title>presentation</title>
     <category>lab</category>
     <number>1</number>
     <content>
     <p>it's no going well...</p>
     </content>
 </topic>
    </daily>
    <daily>
        ....
    </daily>
    </diary>
</diary>
-->

<!-- basic entity -->
<!ENTITY % URI "CDATA">

<!-- inline entity -->
<!ENTITY % phrase "superstrong | strong | strike">
<!ENTITY % special "a">
<!ENTITY % inline "#PCDATA | %phrase; | %special;">

<!-- block entity -->
<!ENTITY % list "list">
<!ENTITY % block "p | code | %list;">

<!-- #### ELEMENT #### -->
<!-- elements -->
<!ELEMENT diary (daily)*>
<!ELEMENT daily (topic)*>
<!ELEMENT topic (category|title|content)*>

<!ELEMENT title (%inline;)*>
<!ELEMENT category (%inline;)*>

<!-- inline elements -->
<!ELEMENT strong (%inline;)*>
<!ELEMENT superstrong (%inline;)*>
<!ELEMENT strike (%inline;)*>
<!ELEMENT a (%inline;)*>
<!ATTLIST a
  href   %URI;   #IMPLIED
  >

<!-- block elements -->
<!ELEMENT p (%inline;)*>
<!ELEMENT code (%inline;)*>

<!-- list elements -->
<!ELEMENT list (item)+>
<!ATTLIST list
  count   (yes | no)   "no"
  >
<!ELEMENT item (%inline;)*>

<!-- end of DML 1.0 DTD -->

---------------------------------------------
% cat sample.xml
<?xml version="1.0" encoding="Shift_JIS" ?>
<?xml-stylesheet type="text/xsl" href="styles/xml/diary.xsl"?>
<!DOCTYPE DIARY SYSTEM
"http://127.0.0.1/~tom/tds/web_diary_dir/styles/xml/diary.dtd">
<diary>
<rdf:RDF
    xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
    xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
    xmlns:dc="http://purl.org/dc/elements/1.0/"
>
<rdf:Description>
 <dc:Creator>TANAKA Tomonari</dc:Creator>
 <dc:Creator.Email>tom@morito.mgmt.waseda.ac.jp</dc:Creator.Email>
 <dc:Title>たわごと日記</dc:Title>
</rdf:Description>
</rdf:RDF>
<daily>
 <date>
  <year>2000</year>
  <month>10</month>
  <day>08</day>
 </date>
 <topic>
  <title>淋しい生活</title>
  <category>palm</category>
  <number>1</number>
  <content>
  <p>
  13日目。
  <strong>STR</strong>
  <strike>striked</strike>
  <a href="foo.html">hoge</a>
  </p>
  </content>
 </topic>
</daily>
</diary>
---------------------------------------------------
% cat diary.xsl
<?xml version="1.0" encoding="Shift_JIS" ?>
<xsl:stylesheet
    xmlns:xsl="http://www.w3.org/TR/WD-xsl"
    xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
    xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
    xmlns:dc="http://purl.org/dc/elements/1.0/"
>

<!-- root note -->
<xsl:template match="/">
 <HTML>
 <HEAD>
 <TITLE><xsl:value-of select="//dc:Title"/></TITLE>
 </HEAD>

 <BODY>
 <H1><xsl:value-of select="//dc:Title"/></H1>
 <HR/>
 <xsl:apply-templates select="/diary"/>
 <HR/>

 <ADDRESS><xsl:value-of select="//dc:Creator"/>
 <A>
  <xsl:attribute name="href">
   <xsl:value-of select="//dc:Creator.Email"/>
  </xsl:attribute>
  &lt; <xsl:value-of select="//dc:Creator.Email"/> &gt;
 </A>
 </ADDRESS>
 </BODY>
 </HTML>
</xsl:template>

<xsl:template match="/diary">
 <xsl:apply-templates select="/diary/daily"/>
</xsl:template>

<xsl:template match="daily">
 <H2><xsl:apply-templates select="date"/></H2>
 <xsl:apply-templates select="topic"/>
</xsl:template>

<xsl:template match="topic">
 <H3>
  <xsl:apply-templates select="number"/>
  <xsl:apply-templates select="category"/>
  <xsl:apply-templates select="title"/>
 </H3>
 <xsl:apply-templates select="content"/>
</xsl:template>

<xsl:template match="number">
 <A>
  <xsl:attribute name="href">
   ?<xsl:value-of select="/diary/daily/date/year"/><xsl:value-of
select="/diary/daily/date/month"/><xsl:value-of
select="/diary/daily/date/day"/>-<xsl:value-of select="text()"/>
  </xsl:attribute>
  <xsl:value-of select="text()"/>
 </A>
</xsl:template>

<xsl:template match="title">
 <xsl:apply-templates/>
</xsl:template>

<xsl:template match="category">
 [<xsl:apply-templates/>]
</xsl:template>

<xsl:template match="content">
 <xsl:apply-templates/>
</xsl:template>

<!-- date node -->
<xsl:template match="date">
 <A>
  <xsl:attribute name="href">
   ?<xsl:value-of select="year"/><xsl:value-of select="month"/><xsl:value-of
select="day"/>
  </xsl:attribute>
  <xsl:value-of select="year"/>/<xsl:value-of select="month"/>/<xsl:value-of
select="day"/>
 </A>
</xsl:template>

<!-- block node -->
<xsl:template match="p">
 <P><xsl:apply-templates/></P>
</xsl:template>

<xsl:template match="code">
 <BLOCKQUOTE><PRE><xsl:apply-templates/></PRE></BLOCKQUOTE>
</xsl:template>


<xsl:template match="hr">
 <HR/>
</xsl:template>

<!-- list node -->
<xsl:template match="list">
 <xsl:if test='@count[.$eq$ "yes"]'>
 <OL>
  <xsl:for-each select="li">
   <LI><xsl:apply-templates/></LI>
  </xsl:for-each>
 </OL>
 </xsl:if>
 <xsl:if test='@count[.$eq$ "no"]'>
 <UL>
  <xsl:for-each select="li">
   <LI><xsl:apply-templates/></LI>
  </xsl:for-each>
 </UL>
 </xsl:if>
</xsl:template>

<!-- inline node -->
<xsl:template match="a">
 <A>
  <xsl:attribute name="href">
   <xsl:value-of select="@href"/>
  </xsl:attribute>
  <xsl:apply-templates/>
 </A>
</xsl:template>

<xsl:template match="strong">
 <STRONG><xsl:apply-templates/></STRONG>
</xsl:template>

<xsl:template match="superstrong">
 <BR/><SPAN ALIGN="center"><STRONG><BIG><FONT
COLOR="#FF0000"><xsl:apply-templates/></FONT></BIG></STRONG></SPAN><BR/>
</xsl:template>

<xsl:template match="strike">
 <S><xsl:apply-templates/></S>
</xsl:template>

<xsl:template match="br">
 <BR/>
</xsl:template>

<xsl:template match="text()">
 <xsl:value-of/>
</xsl:template>

</xsl:stylesheet>

--
tom TANAKA Tomonari
 tom@morito.mgmt.waseda.ac.jp
 http://www.morito.mgmt.waseda.ac.jp/~tom/


スレッド順: ( ←前へ | →次へ | 目次 ) || 日付順: ←前へ | →次へ | 目次 )

Mail converted by MHonArc v2.6.10.

Web日記システムdev MLのページへ

diary-sys-admin@ml.fastwave.gr.jp.
Copyright (C) 1999-2000 Fastwave All rights reserved.
Last Refreshed: 2005/03/01 21:25:37 JST