������������� XML � XSLT ��� �������� LinuxFocus.org(/Nederlands)

ArticleCategory: [Artikel Kategorie]

Applications

AuthorImage:[Bild des Autors]

[���� ������]

TranslationInfo:[Author and translation history]

original in en Egon Willighagen

en to ru Denis Kolobynin

AboutTheAuthor:[Über den Autor]

���������� �������� � ���� ���� ������ ����������� � ������ �������� ��� ���������� ������ ������� ��������� � chemometrics. ����� ����� ���������, �� �� ������ ����� LinuxFocus � Linux.

Abstract:[Zusammenfassung]

��� ������ �������� �������� ����������� �������� �� Libre Software Meeting � Bordeaux. ��� ��������� ���� ������ XML, �������������� ��� �������������� ��������� ������� �� ����� LinuxFocus.org(/Nederlands).

ArticleIllustration:[Titelbild des Artikels]

[�����������]

ArticleBody:[Der eigentliche Artikel]

��������

������� ������������ ������� ������� ��� ���������� ����������� � ���������� �� LinuxFocus, ������� �� ���������� ASCII ������, ����� ��� resdb.txt, issuedb.txtmaindb.txt. ������ ���� ����� ����������, � ������������ ��� ��������� web-�������. �� ����� ������� ������ ���������, � ��������� ���� ������ ������ ������� �������� ���� ���������� � ������ � �� ������.

����� � ������ ����� ���� ������, �������������� ��������� ���������� ������� ����� �������������� �� LinuxFocus. ��� �������� ������������� �������, � �������� ����� ����� �� ����� ������������� �������������� ��������� ��������. �� �������������� ���������� HTML ������ ������ ��� ����� ������������ ����� ������ ������� ����� ������ � ���� ������� �������� ����� ��� ���������� ������ � �������. ��� ������ � ����� ������� ����� ������� � ������� � ��� �� ����� ��������� ���������� � � ������� ����� ���� �� ����� ������������ ��������� �������� ��� �����. � ����� �������� ��� ��� ���-�� ����� 2000 ����.

����� XML ��� ���������� ���������. ������� � ����� ������������ ����������� ���� ������, �� ��������� � ���� ���� �� ������ � XML � ��� �������� ������� ������� ������������ �� ��������� ������, � ������ޣ� XML. ���� ���� ������ ����� ������ ������� ���������, ��������� �� ����� �������������� ��� ��� ��� ��������� ���� ������������. Guido Socher �������� ������ ������ � �������� ��� ������ �� ������������� (�������!).

����������� ���� ��������� (DTD) ��� ��� ���������������, �� ��� ������������ �� ���-��� ������������ � �������. � ����� ������ �������� ���������, ���������� ������ ��������� ���� ������ �����������. ����� ���������� 20 ������, ��� ����� ������� ��� ��������� ������������ ����. ����� ���� �� ������� �������� ������� ��� ������������� ������ ������, �� ��-������ ������������� ���-����� ����������, ������� ������ ���� ��������� � ����� ���� ������, � ��-������, ��� ��� ����������, ���������� ���� �������������� �� ���������� ������. � �������, � ������� ������������� Floris Lambrechts, ������� ������� ������� ����� ���������� � ���� ������. ������� ��� �������, ��� ���� ������� �� ���� �� ������� ��� ��� ��� ����.

������ � ��������� ������ ������� ��������� ����������� ��������� ����� ����������. �� ������� ��� � ���� ������ ���� ��������� ����� ���� ����������. ������ ������������ ������� �������, ������������, ���������� � ������ ����� ��������� � LinuxFocus � ������� ���������� ������. �������� ���������� ����� ���������� ��������� ��, ��� � ������� ��������� LinuxFocus, ������������ ��������� ���� ���������� ������. ����� ������������� �� ����� ����������� �� ����. ��������� ����� ���������� SSI � ����� ���������� .shtml, ����� ������ ������ ���������� ���������� .html. ��� <file> ����� ���� ����������� ��� ��������������� ��������� �� ���������. (������� ��������� ���������� ������ "article" + ����� ������ " + ".shtml". �������� ���������� ".meta", ���� ��� ����-���� LinuxFocus.).

����� ����, ��� ���� ������ �������� ������ ������������ ��������, � ������������ ��������� ������� � ������� �� ������� ��������� ��������������. � ������ ������ ������������ ������� ������ XSLT, ��� ������ �� ������ ����������. ������� ��� ��� �� Perl, �� �� ���� ���������� ������� ���� ������, ������������������ ����� �����, � ������ �������� ��� �������. ����� ��� ��� � ����� ������������ ��� �����������, ������� � ������� ��� ������ ���� ������.

����������� ���� ��������� (Document Type Definition)

������ ����� XML - ��� �������� ���������� ��� ������ ��������. �� ����������, ��� �������� ������ ��������� ���� �������� ������� � ��� ������ ������� ������ �������� �� ������������ ����, ���������� (�����, �������� �������, ��� � �� � ������) � ������������ ����. ���� ������ �������� �� ������� "<" �� ������� ������� �������� ���� � �������� ������ ">". � ����������� ���� ����� ������ ������ ������ ������ "/". �����, ����������� ��� ����� ��������� ���������, ������� ���� ����� ���� ����������� ���������. ����� ������� ��������� ��������� ������������������ �������� � ������� ������� ����� �������� ���������� XML ��������. �������� XML ��������� ����� ������� ��������� �����:

<greeting>Hello, world!</greeting>

����� ����������, ����� ����� �������� ���������. ��� ���������� ��� ������ ������� ������ � �������. ���� ����� ��� ������� HTML, �� � ��� ��������� ���������� ��� ��� <html> ������ ��������� ��� <body>, � �� ��������. ����� ������������ ��� ��� <img> � ��� <br> ������. ���� ��������� ���� � ���������� �������, �� � ������� �� ��������� ����� ��������� ��������. ���� �� ����������� ������� ���������� Document Type Definition (����������� ���� ���������), ������� DTD. ���� �������� �������� ��������, �� ���������� ���������� XML ����������.

������, ����� ���� ��� �� ������ ��� ����� DTD, ������� �������� �� LinuxFocus XML Database DTD. ��� ��������� ����������� ����� ���� �������. ������ ��� ������� �� �������� ������������� � ��� ��� �������� ���������� � XML ���� ������.

<database>

�������� ������� XML ���� ������ LinuxFocus, ��� ���� �� �� ���������� ��� ����������� - ������� <database>.

<!ELEMENT database    (themes?, persons?, issues?, articles?)>
    

���� "?" �������������, ��� �������� ������� ����� �� ��������� ��� ��������� ������ ���� ���. ����� �������, ���� ������ ����� ��������� ���������� � ��������, ���������, �������� � �������. ����� �ӣ ������, ������� ������� �����ģ� � ����� ����������� �������.

<themes>

��� ���� �������� � �������� <themes>, ������� �������� �������� ��� �������� <database>. ������ ���� ����� ���������� ID (����������������� �����), �������� � ��� �������������� �������� - ������ � �����������.

<!ELEMENT themes      (theme+)>
  <!ELEMENT theme       (title*, desc?, img?)>
    <!ELEMENT title       (#PCDATA)>
    <!ELEMENT desc       (#PCDATA)>
    <!ELEMENT img         (EMPTY)>
    

��������� �� ���� ��������� ������ ����� ���������. ��� ����� ����������� � DTD. � ������� �������� ����������� ����� ���� �������� xml:lang. ���� �������� ���������� ���� ������. �������� - "en", "fr" � "nl". ��������� id � xml:lang ���������� � ������������ ������������ XML � �������� ������ ���������� XML.

<!ATTLIST theme       id            ID            #REQUIRED>
<!ATTLIST title       xml:lang      NMTOKEN       #REQUIRED>
<!ATTLIST desc        xml:lang      NMTOKEN       #REQUIRED>
<!ATTLIST img         src           CDATA         #REQUIRED>
    

���� ������ ����� ��������� ���:

<database>
  <themes>
    <theme id="hw">
      <title xml:lang="en">Hardware</title>
      <img src="Hardware.jpg"/>
    <theme>
  <themes>
</database>
    

<issues>

������ ���������� � �������� <issues>. ����� ��� � ���� ������ ����� ����� ���������� ID

<!ELEMENT issues      (issue+)>
  <!ELEMENT issue       (title+, published?, file*)>
    <!ELEMENT title       (#PCDATA)>
    <!ELEMENT published   (EMPTY)>
    <!ELEMENT file        (#PCDATA)>
    

������� <published> ���������� ����������� ����� ��� ���. ��������� ����� � ������-������ SomeLanguage2Eng �� ����� ����� ��������. ������� <title> ����� �� �������� �������� @xml:lang. ������� <file> ���������� ������� � ������� �������� �����. �� �� ������ ��������� �� index.html, ��������� � ����������� ����� �������������� ��� ����������� ���������� ������.

������ (�������� @code ������ ��� ����������):

    <issue id="ToBeWritten" code="999996">
      <title xml:lang="en">Not yet written articles</title>
    </issue>
    <issue id="September2001" code="200109">
      <title xml:lang="en">September2001</title>
    </issue>

<persons>

���������� �� ������� � ������������ �������� � �������� <person>. ������ ������� ����� ���������� ID.

  <!ELEMENT persons     (person+)>
    <!ELEMENT person      ((name|email)*,(homepage|nickname|desc|team)*)>
      <!ELEMENT email       (#PCDATA)>
      <!ELEMENT name        (#PCDATA)>
      <!ELEMENT homepage    (#PCDATA)>
      <!ELEMENT nickname    (#PCDATA)>
      <!ELEMENT desc        (#PCDATA|%html-els;)*>
      <!ELEMENT team        EMPTY>
    

������ ������� ����� ����� ��������� ����������: ���, ����� ����������� ����� (��� ���������), ����� �������� ��������� (��� ���������) � ��������. ���� ������� ����� �������� ������ ������� ������������, �� ����������� ������� <team>. ��� ���� ����� �����, ��������, ��� Floris ���� ������������� ������ � ������� <person> ����������� ��������� ������: <team xml:lang="nl"/>. ������� ������ ������� ����� ����� ��������, ������� ����� ��������� �������������� ������.

������:

    <person id="nl-ew">
      <name>Egon Willighagen</name>
      <email>egonw@linuxfocus.org</email>
      <team xml:lang="nl"/>
    </person>

<articles>

���������� ������ �������� �������� ���������� ������ ���� ������.

  <!ELEMENT articles    (article+)>
    <!ELEMENT article     (title+, 
        (file|personref|abstract|issueref|themeref|
         nometa|nohtml|translation|proofread)*)>
      <!ELEMENT abstract    (#PCDATA)>
      <!ELEMENT nohtml      EMPTY>
      <!ELEMENT nometa      EMPTY>
      <!ELEMENT translation (personref*, (reserved|finished|proofread)*)>
        <!ELEMENT reserved    (#PCDATA)>
        <!ELEMENT finished    (#PCDATA)>
        <!ELEMENT proofread   (personref*, (reserved|finished)*)>
<!ATTLIST article     id            ID            #REQUIRED
                      xml:lang      NMTOKEN       #IMPLIED
                      type          (article|coverpage)
                                                  "article"
                      next          IDREF         #IMPLIED
                      prev          IDREF         #IMPLIED>
<!ATTLIST file        xml:lang      NMTOKEN       #REQUIRED
                      type          (target|meta) "target">
<!ATTLIST translation from          NMTOKEN       #REQUIRED
                      to            NMTOKEN       #REQUIRED>

    

������ ������ ����� �� ������� ���� ���� ���������; ���� ��� ������� �����. ������� <file> ����� ���� ����������� ��� ������� ���������� ����� ������, ��� META � HTML ������ (������ ������ ����). ���� �� META �� HTML ������ ������ �� ��������, ����� �������������� ���� <nohtml/> � <nometa/>. ������ ������ ����� ����� ������� �����. ��� ������ ������������ � ���� ������ ����� ���� ������������ ��� �������������� �������.

������� <article> ����� ���� ����������: ������������ @ID, �������������� �������� xml:lang ��� ����������� ����� �� ������� �������� ������, �������� @type ������������ ��� �������, ������� ��� �������� �������� ����� ������������ ��� ������. � ������� ��� �������������� ��������� - @next � @prev, ������� ������������ ��� ����� ������ � �����.

������ ������� � ������� � ����� ���������� <issueref> � <themeref>, ������� ����� �������� @href. ��������� ����� ��������� �������� ���������� ������������� - ID ������� ������ ��� ����.

������:

    <article id="article206" xml:lang="en">
      <title xml:lang="en">Using XML and XSLT to build 
        LinuxFocus.org(/Nederlands)</title>
      <personref href="nl-ew"/>
      <issueref href="ToBeWritten"/>
      <themeref href="appl"/>
      <abstract xml:lang="en">
This article shows you how parts of the Dutch web site of LinuxFocus is 
generated with XSLT tools from the XML database. It compares this with 
the (very) much slower DOM tools in Perl.
      </abstract>
    </article>

������������� ������ �������� <article> ����� ��������� ���:

    <article id="52">
      <title xml:lang="nl">Enlightenment</title>
      <file xml:lang="nl">Nederlands/July1998/article52.html</file>
      <translation from="en" to="nl">
        <personref href="nl-tu"/>
        <reserved>2000-09-06</reserved>
        <finished>2000-10-04</finished>
        <proofread>
          <personref href="nl-fl"/>
          <reserved>2000-10-04</reserved>
          <finished>2000-10-04</finished>
        </proofread>
      </translation>
      <abstract xml:lang="nl">
Enlightenment is een Linux window-manager met uitgebreide mogelijkheden. 
Dit artikel bespreekt ze, samen met de installatie en de instelling van E. 
Dit alles is niet voor beginners daar E op het moment nog in beta-stadium 
verkeert.
      </abstract>
    </article>

����� ��������, ��� ������� ����� � ������̣���� ����, ��������, �� � ������ ������ ��������� � �������. � ����� ������ �������, ������� ������ ������, ������������ ���������� <personref>.

��� ���� ��������� ��������� ��������� ����� ������� ���� ���� ������:

�������������� �������� web-�������

����� �� ������ ��� �������� ������ ������� ���� ������ �������� �������������� ��������� �������. ������, ����� �� ����������� � �������� ���� ������, ������� ��������� ��� �� ����� ������������ � ������� ��� web-��������.

������� ������� �������. ������ ���������� ������������ Perl-������ ��� ����� � ����� ������. �������� �� ��, ��� ��������� ����� �����, ���������� ���� ����� ���������. ����� ���������� ����������� � XML ���������� ���������� Document Object Model (DOM). ����������� ���������� ��� DOM, ����� ��������, �� ������� ���� ������� �������� ��� �������������� Simple Application interface for XML (SAX).

���� ������� ����� ������ ���� ��������� web-������� �� ��������� ��������� �������� ����� ������: XSLT. ��� ��������� �� XML ���� �������������. �� ������ ������ ���������� ������� ���������� XSLT ����������� � �������������� ����������� ������ ����������������. ��������� ����� ����� ���� ������ �� LinuxFocus XML::XSLT, ���� �� ���������� �� Perl XSLT. �� ������ ���������� ���� ������, ����� ����� ���������� � � ���� ��� ��������������� ���������:

������������� ������� ���������� Sablotron.

XSLT ��������� �������� ��� ����� �� �����. ���� �� ���, ��� XML-�������� ������� ������ ���� ���������������. ������ - ������� ������ XSLT, ������� ���������� ������ �������������. ��� ��������� web-������� LinuxFocus ������������ ��������� ������� ������ XSLT:

�������� ��� ����, ����� ������������� mainindex.html, ������������� ������� ���������:

sabcmd stylesheets/mainindex.xslt db/lfdb.nl.xml > ../mainindex.html

������� ������ ��������� � ����� ���������� ���� ������, � ������� �� ���� ������ �������������� XML ���� ������. ��������� �� ��� ������� �������������� ����������:

sabcmd stylesheets/theme.xslt db/lfdb.nl.xml '$theme=appl' > ../Themes/appl.html

������������� index.html ����� ������������ �� ���� ������, �� ���������� ������� ����� ������� ��������. index.html ���������� � ������� lfpagecomposer Guido Socher'� �� ����� �������������� ����������� �������� ������. ��� ����� � ���� ������� ������������ � ������� *.pre ������. ��� ������ ������ �����:

  <H2>Vorige nummers</H2>
 
<p>Dit zijn de uitgaven van LinuxFocus in het Nederlands:
<ul>
<!-- macro xslt previssues -->
</ul>

��������� ����������� �������� ��������� apply_stylesheets.pl ������� ���� ������� <!-- macro xslt [stylesheet] --> � ��������� � ������� �ţ ���� ������. ��������, ��� ���������� .xslt �������. ��� Makefile ��������:

%.shtml: %.pre
        @echo "Making $*..."
        @../../xml/bin/apply_stylesheets.pl $*.pre

��������� *.shtml ����� ������������ �������� lfpagecomposer. ������� ������, ������� ������������ ��� ��������� index.html ���������: issuetoc.xslt, previssues.xslt � recently_translated.xslt.

�������� �����������

��� ������������� ���� ������� ��� ������ ������, ��� ���� ������� ���������:

  1. ������������ XML ���� ������ (��� lfdb.nl.xml)
  2. ������������ ������� ������

������� ������ ���� ����� ������� ��� ������. � �������� ������ ����� �� ������ ������ ���� �����������, �� ������� ������ ���� �� ����� ������� ��� ����������� �����������. ��� �� �� �� ���� ����������� ��� ��������.

� ���� ��������������� �������� XML � ���������� DTD. �� Emac �� ������ ������������ �������� �������� ����� psgml. nsgmls) ����������� ��� ����������� �������� ����������. ��� ������� �������� ������. � Emac �� ����� ������ ����� ������ ������ ���� ������� �������� � ���������, ������� ����� �������� � ������̣���� ����� � XML ���������.

���� � ��� ��������� �����-�� �������� �� ������ ������ �������� ��� ������. ���� ��� �� �������, ������ ���������� �� ���

����������� ������ ������ ���������. ����� ��������� ������ � ��������� XSLT. ������� ��� ������� �� ����� (���� ������ �� ������ ��� �������), ����� �� �������� ����������������. � �������� � ������� ������� ����� ������� ������, ������� ������������ �������������� ���������� ����� �� ����������� XSLT ������.

����� �� �������

� ������� ��� ������ ������� ��� ������ ������. ������� ����� ������ ����� ���� ����������� � ������������� ������. ��� ����� ��������� ��� ��������� FDL � GPL. � ��� ��� ����� �� ��������� ���: