docs-common/packaging get-all-workers.xsl, NONE, 1.1 get-worker.xsl, NONE, 1.1 insert-changelog.xsl, NONE, 1.1 insert-colophon.xsl, NONE, 1.1

Paul W. Frields (pfrields) fedora-docs-commits at redhat.com
Sun Jan 15 17:05:24 UTC 2006


Author: pfrields

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

Added Files:
	get-all-workers.xsl get-worker.xsl insert-changelog.xsl 
	insert-colophon.xsl 
Log Message:
These snippets will be useful in Makefile.common, since they enable:

1. inserting new worker and revision elements (both newest-first of course!)
2. querying the document for a tight listing of the entire colophon, so the user can choose who is responsible for a new revision
3. querying the document for a specific worker attribute

The "make worker" target idea is simple enough, but more importantly, the use case for a "make clog" target would be:

1. User picks whether revision role is "rpm" or "doc", today's date is formatted properly for the role
2. User picks their name from the tight colophon listing
3. The make target automatically queries for the worker attribute appropriate for that revision role (e.g. initials for doc, email for rpm)




--- NEW FILE get-all-workers.xsl ---
<!-- Get a list of all workers (full name and email address) -->

<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:template match="/">
    <xsl:for-each select="/rpm-info/colophon/worker"><xsl:value-of
	select="@email"/>:<xsl:value-of select="@wholename"/>
    </xsl:for-each>
  </xsl:template>

</xsl:stylesheet>


--- NEW FILE get-worker.xsl ---
<!-- 

Get a worker attribute by name for a specific worker.
  pos : param, integer for position (default: 1)
  att : stringparam, name of attribute to fetch (default: email)
N.B.: xml:space attribute not set to avoid output ugliness

-->

<xsl:stylesheet version="1.0" 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="pos" select="1"/>
  <xsl:param name="att" select="'email'"/>
  <xsl:strip-space elements="*"/>

  <xsl:template match="/">
    <xsl:for-each select="/rpm-info/colophon/worker[$pos]">
      <xsl:choose>
	<xsl:when test="$att='email'"><xsl:value-of select="@email"/></xsl:when>
	<xsl:when test="$att='wholename'"><xsl:value-of
	    select="@wholename"/></xsl:when>
	<xsl:when test="$att='id'"><xsl:value-of select="@id"/></xsl:when>
	<xsl:otherwise><xsl:text>ERROR</xsl:text></xsl:otherwise>
      </xsl:choose>
    </xsl:for-each>
  </xsl:template>

</xsl:stylesheet>


--- NEW FILE insert-changelog.xsl ---
<!-- 

Add a RPM changelog entry to a document's rpm-info.xml file.
The following stringparam values are expected in this file:
  detail : Text describing the change
    date : Date of change, formatted properly:
             For role="rpm", date format is +"%a %b %d %Y"
             For role="doc", date format is +"%Y-%m-%d"
  number : Number for change, formatted properly:
             For role="rpm", integer release number
             For role="doc", version number for document
  person : ID for responsible entity, drawn from current <colophon>
    role : "doc" or "rpm", indicating type of change

-->

<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:template match="/">
    <xsl:apply-templates/>
  </xsl:template>

  <xsl:template match="rpm-info">
    <xsl:element name="rpm-info">
      <xsl:for-each select="*">
	<xsl:choose>
	  <xsl:when test="self::changelog"><xsl:call-template name="clog"/></xsl:when>
	  <xsl:otherwise><xsl:copy-of select="."/></xsl:otherwise>
	</xsl:choose>
      </xsl:for-each>
    </xsl:element>
  </xsl:template>

  <xsl:template name="clog">
    <xsl:element name="changelog" use-attribute-sets="clog">
      <xsl:element name="revision" use-attribute-sets="rev">
	<xsl:element name="author" use-attribute-sets="auth"/>
	<xsl:comment>PLEASE SET "lang" ATTRIBUTE IN DETAILS WHERE NEEDED</xsl:comment>
	<xsl:element name="details"><xsl:value-of
	select="$detail"/></xsl:element>
      </xsl:element>
      <xsl:copy-of select="*"/>
    </xsl:element>
  </xsl:template>


  <xsl:attribute-set name="clog">
    <xsl:attribute name="order">newest-first</xsl:attribute>
  </xsl:attribute-set>

  <xsl:attribute-set name="rev">
    <xsl:attribute name="date"><xsl:value-of select="$date"/></xsl:attribute>
    <xsl:attribute name="number"><xsl:value-of
    select="$number"/></xsl:attribute>
    <xsl:attribute name="role"><xsl:value-of select="$role"/></xsl:attribute>
  </xsl:attribute-set>

  <xsl:attribute-set name="auth">
    <xsl:attribute name="worker"><xsl:value-of
    select="$person"/></xsl:attribute>
  </xsl:attribute-set>

</xsl:stylesheet>


--- NEW FILE insert-colophon.xsl ---
<!-- 

Add a worker to a document's colophon. The following stringparam values are
required and expected:
  firstname : Contributor's first name
    surname : Contributor's family or surname
   initials : Initials for use in document revision history
      email : email address (should match Fedora Project email)

The following stringparam values are optional:
  othername : Middle initial

The following stringparam values will be set in this stylesheet:
  wholename : firstname + " " [ + othername + " " ] + surname
         id : firstname + surname

-->

<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"/>

  <!-- Cope if no othername is provided -->
  <xsl:param name="othername" select="''"/>

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

  <xsl:template match="rpm-info">
    <xsl:element name="rpm-info">
      <xsl:for-each select="*">
	<xsl:choose>
	  <xsl:when test="self::colophon">
	    <xsl:call-template name="colophon">
	      <xsl:with-param name="firstname"><xsl:value-of
		  select="$firstname"/></xsl:with-param>
	    </xsl:call-template>
	  </xsl:when>
	  <xsl:otherwise><xsl:copy-of select="."/></xsl:otherwise>
	</xsl:choose>
      </xsl:for-each>
    </xsl:element>
  </xsl:template>

  <xsl:template name="colophon">
    <xsl:element name="colophon">
      <xsl:element name="worker" use-attribute-sets="person"/>
      <xsl:copy-of select="*"/>
    </xsl:element>
  </xsl:template>

  <xsl:attribute-set name="person">
    <xsl:attribute name="firstname"><xsl:value-of
	select="$firstname"/></xsl:attribute>
    <xsl:attribute name="othername"><xsl:value-of
	select="$othername"/></xsl:attribute>
    <xsl:attribute name="surname"><xsl:value-of
	select="$surname"/></xsl:attribute>
    <xsl:attribute name="initials"><xsl:value-of
	select="$initials"/></xsl:attribute>
    <xsl:attribute name="email"><xsl:value-of select="$email"/></xsl:attribute>
    <xsl:attribute name="wholename"><xsl:value-of select="$firstname"/> <xsl:if
	test="$othername"><xsl:value-of select="$othername"/> </xsl:if><xsl:value-of select="$surname"/></xsl:attribute>
    <xsl:attribute name="id"><xsl:value-of select="$firstname"/><xsl:value-of
	select="$surname"/></xsl:attribute>
  </xsl:attribute-set>

</xsl:stylesheet>




More information about the Fedora-docs-commits mailing list