docs-common/packaging bookinfo.xsl, NONE, 1.1 desktop.xsl, NONE, 1.1 omf.xsl, NONE, 1.1 rpm-info.dtd, NONE, 1.1 spec.xsl, NONE, 1.1

Tommy Reynolds (jtr) fedora-docs-commits at redhat.com
Fri Nov 25 20:53:00 UTC 2005


Author: jtr

Update of /cvs/docs/docs-common/packaging
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv29637/docs-common/packaging

Added Files:
	bookinfo.xsl desktop.xsl omf.xsl rpm-info.dtd spec.xsl 
Log Message:
Candidate solution to keeping all the various RPM packaging files
(the RPM spec file, the OMF file, the ".desktop" and the package's
<bookinfo> (or <articleinfo>) consistent by using a DTD-controlled metafile
from which everything else is derived.



--- NEW FILE bookinfo.xsl ---
<!-- Transform rpm-info.xml into either "bookinfo" or "articleinfo" -->
<xsl:stylesheet version="1.0" xml:space="preserve" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:output encoding="UTF-8" indent="yes" method="xml" omit-xml-declaration="yes" standalone="no" version="1.0"/>

    <xsl:param name="lang" select="'en'"/>
    <xsl:param name="doctype" select="'bookinfo'"/>

    <xsl:template match="/">
        <xsl:element name="{$doctype}">
            <title>
                <xsl:call-template name="get-title"/>
            </title>
            <copyright>
                <year>
                    <xsl:value-of select="/rpm-info/copyright/year"/>
                </year>
                <xsl:for-each select="/rpm-info/copyright/holder">
                    <holder>
                        <xsl:value-of select="node()"/>
                    </holder>
                </xsl:for-each>
            </copyright>
            <authorgroup>
                <xsl:for-each select="/rpm-info/author">
                    <author>
                        <xsl:call-template name="human"/>
                    </author>
                </xsl:for-each>
                <xsl:for-each select="/rpm-info/translator">
                    <othercredit>
                        <xsl:call-template name="human"/>
                        <personalblurb>Translator</personalblurb>
                    </othercredit>
                </xsl:for-each>
                <xsl:for-each select="/rpm-info/editor">
                    <editor>
                        <xsl:call-template name="human"/>
                    </editor>
                </xsl:for-each>
            </authorgroup>
            <xsl:text disable-output-escaping="yes">&amp;LEGALNOTICE;</xsl:text>
            <revhistory>
                <xsl:for-each select="/rpm-info/changelog/revision">
                    <revision>
                        <revnumber><xsl:value-of select="@version"/></revnumber>
                        <date><xsl:value-of select="@date"/></date>
                        <authorinitials><xsl:value-of select="author/@initials"/></authorinitials>
                        <revdescription>
                            <para>
                                <xsl:value-of select="details"/>
                            </para>
                        </revdescription>
                    </revision>
                </xsl:for-each>
            </revhistory>
        </xsl:element>
    </xsl:template>

    <xsl:template name="get-title">
        <xsl:for-each select="/rpm-info/titles/translation">
            <xsl:choose>
                <xsl:when test="@lang = $lang">
                    <xsl:value-of select="title"/>
                </xsl:when>
            </xsl:choose>
        </xsl:for-each>
    </xsl:template>

    <xsl:template name="human">
        <surname><xsl:value-of select="@surname"/></surname>
        <firstname><xsl:value-of select="@firstname"/></firstname>
    </xsl:template>
</xsl:stylesheet>


--- NEW FILE desktop.xsl ---
<!-- Transform rpm-info.xml into a .desktop File -->
<xsl:stylesheet version="1.0" xml:space="preserve" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:output encoding="UTF-8" indent="no" method="text" omit-xml-declaration="no" standalone="no" version="1.0"/>

<!-- Note: do not indent this file!  Any whitespace here
     will be reproduced in the output -->

  <xsl:param name="lang" select="'en'" />
  <xsl:param name="docbase" select="'example-tutorial'" />
  <xsl:param name="release"	select="1"/>

<xsl:template match="/">
[Desktop Entry]
Encoding=UTF-8
Categories=X-Fedora-Documentation
GenericName=<xsl:value-of select="/rpm-info/titles/translation[@lang='en']/title"/>
Name=<xsl:value-of select="/rpm-info/titles/translation[@lang='en']/title"/>
Exec=gnome-help file://usr/share/doc/fedora-doc-<xsl:value-of select="$docbase"/>/en/<xsl:value-of select="$docbase"/>-en.xml
<xsl:for-each select="/rpm-info/titles/translation">
Name[<xsl:value-of select="@lang"/>]=<xsl:value-of select="title"/>
Comment[<xsl:value-of select="@lang"/>]=<xsl:value-of select="desc"/>
Exec[<xsl:value-of select="@lang"/>]=gnome-help file://usr/share/doc/fedora-doc-<xsl:value-of select="$docbase"/>/<xsl:value-of select="@lang"/>/<xsl:value-of select="$docbase"/>-<xsl:value-of select="@lang"/>.xml
</xsl:for-each>

</xsl:template>

  <xsl:template name="get-title">
    <xsl:for-each select="/rpm-info/titles/translation">
      <xsl:choose>
	<xsl:when test="@lang = $lang">
	  <xsl:value-of select="title"/>
	</xsl:when>
      </xsl:choose>
    </xsl:for-each>
  </xsl:template>

</xsl:stylesheet>


--- NEW FILE omf.xsl ---
<!-- Transform rpm-info.xml into an OMF file -->
<xsl:stylesheet version="1.0" xml:space="preserve" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:output doctype-public="-//OMF//DTD Scrollkeeper OMF Variant V1.0//EN" doctype-system="http://scrollkeeper.sourceforge.net/dtds/scrollkeeper-omf-1.0/scrollkeeper-omf.dtd" encoding="UTF-8" indent="yes" method="xml" omit-xml-declaration="no" standalone="no" version="1.0"/>

<!-- Note: do not indent this file!  Any whitespace here
     will be reproduced in the output -->

  <xsl:param name="lang" select="'en'" />
  <xsl:param name="docbase" select="'example-tutorial'" />

  <xsl:template match="/">
    <omf>
      <resource>
        <creator>
          fedora-docs-list at redhat.com (Fedora Documentation Project)
        </creator>
        <maintainer>
          fedora-docs-list at redhat.com (Fedora Documentation Project)
        </maintainer>
        <title>
          <xsl:call-template name="get-title"/>
        </title>
        <date>
          <xsl:value-of select="/rpm-info/changelog/revision[1]/@date"/>
        </date>
        <version
          identifier="{/rpm-info/changelog/revision[1]/@version}"
          date="{/rpm-info/changelog/revision[1]/@date}"
          description="{$docbase}-{/rpm-info/changelog/revision[1]/@version} ({/rpm-info/changelog/revision[1]/@date})"
        />
        <subject category="General|Linux|Distributions|Other"/>
        <description>
          <xsl:call-template name="get-title"/>
        </description>
        <type>
          <xsl:call-template name="get-title"/>
        </type>
        <format mime="text/xml" dtd="-//OASIS//DTD DocBook XML V4.2//EN"/>
        <identifier url="file:/usr/share/fedora/doc/fedora-doc-{$docbase}/{$lang}/{$docbase}-{$lang}.xml" />
        <language code="{$lang}"/>
        <relation seriesid="7a5d3ea2-2a1e-11da-86a3-8ea47a4bb227"/>
        <rights type="GNU FDL" license.version="1.1" />
      </resource>
    </omf>
  </xsl:template>

  <xsl:template name="get-title">
    <xsl:for-each select="/rpm-info/titles/translation">
      <xsl:choose>
        <xsl:when test="@lang = $lang">
          <xsl:value-of select="title"/>
        </xsl:when>
      </xsl:choose>
    </xsl:for-each>
  </xsl:template>

</xsl:stylesheet>


--- NEW FILE rpm-info.dtd ---
<!--
  DTD for the Fedora Docs Project RPM Information file "rpm-info.xml"
-->

<!ELEMENT rpm-info		(release,author+,translator*,editor*,
				license,copyright+,titles,changelog)	>

<!ELEMENT release		EMPTY					>
<!ATTLIST release	rel	CDATA		#REQUIRED		>

<!ELEMENT license		(rights,license.version)		>
<!ELEMENT rights		(#PCDATA)				>
<!ELEMENT license.version	(#PCDATA)				>

<!ELEMENT copyright		(year,holder+)				>
<!ELEMENT year			(#PCDATA)				>
<!ELEMENT holder		(#PCDATA)				>

<!ELEMENT titles	 	(translation+) 				>

<!ELEMENT translation		(title,desc)*				>
<!ATTLIST translation	lang 	CDATA		#REQUIRED		>

<!ELEMENT title			(#PCDATA)				>
<!ELEMENT version 		(#PCDATA)     				>
<!ELEMENT desc			(#PCDATA)				>

<!ELEMENT changelog		(revision+)				>
<!ATTLIST changelog 	order  	(newest-first)  #REQUIRED 		>

<!ELEMENT revision		(author+,editor*,details)		>
<!ATTLIST revision  	date   	CDATA   	#REQUIRED 		>
<!ATTLIST revision  	version	CDATA   	#REQUIRED 		>

<!ELEMENT author  		EMPTY					>
<!ATTLIST author	wholename CDATA   	#REQUIRED 		>
<!ATTLIST author	email     CDATA   	#REQUIRED 		>
<!ATTLIST author  	surname   CDATA   	#REQUIRED 		>
<!ATTLIST author  	firstname CDATA   	#REQUIRED 		>
<!ATTLIST author  	initials  CDATA		#REQUIRED 		>

<!ELEMENT editor  			EMPTY				>
<!ATTLIST editor	wholename CDATA   #REQUIRED 			>
<!ATTLIST editor	email     CDATA   #REQUIRED 			>
<!ATTLIST editor  	surname   CDATA   #REQUIRED 			>
<!ATTLIST editor  	firstname CDATA   #REQUIRED 			>


<!ELEMENT translator  			EMPTY				>
<!ATTLIST translator	wholename CDATA   #REQUIRED 			>
<!ATTLIST translator	email     CDATA   #REQUIRED 			>
<!ATTLIST translator	surname   CDATA   #REQUIRED 			>
<!ATTLIST translator  	firstname CDATA   #REQUIRED 			>

<!ELEMENT details		(#PCDATA)				>


--- NEW FILE spec.xsl ---
<!-- Transform rpm-info.xml into a SPEC File -->
<xsl:stylesheet version="1.0" xml:space="preserve" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:output encoding="UTF-8" indent="no" method="text" omit-xml-declaration="no" standalone="no" version="1.0"/>

<!-- Note: do not indent this file!  Any whitespace here
     will be reproduced in the output -->

  <xsl:param name="lang" select="'en'" />
  <xsl:param name="docbase" select="'example-tutorial'" />
  <xsl:param name="release"	select="1"/>

<xsl:template match="/">
# Fedora Documentation Specfile
%define	docbase	<xsl:value-of select="$docbase"/>
%define release	<xsl:value-of select="$release"/>
#
Summary:	Fedora Documentation: %{docbase}
Name:		fedora-doc-%{docbase}
Version:	<xsl:value-of select="/rpm-info/changelog/revision[1]/@version"/>
Release:	<xsl:value-of select="/rpm-info/release/@rel"/>
License:	<xsl:value-of select="/rpm-info/license/rights"/>
Url:		http://fedora.redhat.com/projects/docs
Source0:	%{docbase}-%{version}.src.tar.gz
Source1:	%{name}.desktop
<xsl:for-each select="/rpm-info/titles/translation">
Source<xsl:value-of select="position()+1" />:	%{name}-<xsl:value-of select="@lang"/>.omf</xsl:for-each>
Group:		Documentation
BuildArch:	noarch
BuildRoot:	%{_tmppath}/%{name}-%{version}-root
Requires:	scrollkeeper &gt;= 0.3.11
Requires:	fedora-doc-common
BuildRequires:	xmlto

%description
<xsl:value-of select="/rpm-info/titles/translation[@lang='en']/desc" />

<xsl:for-each select="/rpm-info/titles/translation">
%description	<xsl:value-of select="@lang"/>
<xsl:value-of select="desc"/>
</xsl:for-each>

%prep
%setup -q -n %{docbase}-${version}
	for in in $RPM_BUILD_DIR/%{docbase}-%{version}/%{docbase}*.xml
	do
		%{__sed} -i 's;../docs-common;../../docs-common;' "$i"
	done

%build
#	/bin/rm -r $RPM_BUILD_ROOT
#	/usr/bin/install -d -m 0755 $RPM_BUILD_ROOT/%{_datadir}/omf/%{name}

%clean
	/bin/rm -rf $RPM_BUILD_ROOT

<xsl:for-each select="/rpm-info/titles/translation">
%post	<xsl:value-of select="@lang"/>
	/usr/bin/scrollkeeper-update || true
%postun	<xsl:value-of select="@lang"/>
	/usr/bin/scrollkeeper-update || true
%files	<xsl:value-of select="@lang"/>
%defattr(-, root, root, -)
</xsl:for-each>
</xsl:template>

  <xsl:template name="get-title">
    <xsl:for-each select="/rpm-info/titles/translation">
      <xsl:choose>
	<xsl:when test="@lang = $lang">
	  <xsl:value-of select="title"/>
	</xsl:when>
      </xsl:choose>
    </xsl:for-each>
  </xsl:template>

</xsl:stylesheet>




More information about the docs-commits mailing list