Howto customize title for legalnotice

View: New views
8 Messages — Rating Filter:   Alert me  

Howto customize title for legalnotice

by spr :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I want the title "IMPORTANT NOTICE" generated for "legalnotice" to be in red color.

But unable to get it working with code below:
  <xsl:attribute-set name="formal.title.properties">
  <xsl:attribute name="color">
    <xsl:choose>
      <xsl:when test = "parent::legalnotice">red</xsl:when>
      <xsl:otherwise>black</xsl:otherwise>
    </xsl:choose>
  </xsl:attribute>

Also tried "parent::info/legalnotice" in the test above.

What could be going wrong?

Is there a command-line tool that would tell me which XSL template is being applied during transformation?
Would save may such queries?

~spr
~spr

Re: Howto customize title for legalnotice

by Bob Stayton :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,
The test is failing because the context node is legalnotice, not
legalnotice/title.  A legalnotice is handled by the template with
match="legalnotice" and mode="titlepage.mode" in fo/titlepage.xsl.  It
calls the formal.object.heading template, with the context still being the
legalnotice element.  That template applies the formal.title.properties
attribute set.  So change:

parent::legalnotice

to

self::legalnotice

and it should work.

Most of the templates handling titles work with the container of the title
through most of the process.  That's largely because a given element's
title could come from more than one element, e.g.,  book/title or
book/info/title.

I don't know of a command line tool that reveals which templates are being
used.  If someone writes one, please let me know!  I generally use an XSL
debugger like Oxygen when I have to follow the template sequence.

Bob Stayton
Sagehill Enterprises
DocBook Consulting
bobs@...


----- Original Message -----
From: "spr" <spremi@...>
To: <docbook-apps@...>
Sent: Thursday, October 04, 2007 4:54 AM
Subject: [docbook-apps] Howto customize title for legalnotice


>
> I want the title "IMPORTANT NOTICE" generated for "legalnotice" to be in
> red
> color.
>
> But unable to get it working with code below:
>  <xsl:attribute-set name="formal.title.properties">
>  <xsl:attribute name="color">
>    <xsl:choose>
>      <xsl:when test = "parent::legalnotice">red</xsl:when>
>      <xsl:otherwise>black</xsl:otherwise>
>    </xsl:choose>
>  </xsl:attribute>
>
> Also tried "parent::info/legalnotice" in the test above.
>
> What could be going wrong?
>
> Is there a command-line tool that would tell me which XSL template is
> being
> applied during transformation?
> Would save may such queries?
>
> ~spr
> --
> View this message in context:
> http://www.nabble.com/Howto-customize-title-for-legalnotice-tf4568304.html#a13038248
> Sent from the docbook apps mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: docbook-apps-unsubscribe@...
> For additional commands, e-mail: docbook-apps-help@...
>
>
>



---------------------------------------------------------------------
To unsubscribe, e-mail: docbook-apps-unsubscribe@...
For additional commands, e-mail: docbook-apps-help@...


Re: Howto customize title for legalnotice

by spr :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Did not work :(

  <xsl:attribute-set name="formal.title.properties">
  <xsl:attribute name="color">
    <xsl:choose>
      <xsl:when test = "self::legalnotice">red</xsl:when>
      <xsl:otherwise>black</xsl:otherwise>
    </xsl:choose>
  </xsl:attribute>

Did try to go thru the fo/titlepage.xsl -> formal.object.heading -> formal.title.properties.

I believe that it should have workerd, but like some other issues that I have posted, i am loosing faith the the 'fop'. Will setup and use standalone xslt processor and see if it makes difference.

~spr


Hi,
The test is failing because the context node is legalnotice, not
legalnotice/title.  A legalnotice is handled by the template with
match="legalnotice" and mode="titlepage.mode" in fo/titlepage.xsl.  It
calls the formal.object.heading template, with the context still being the
legalnotice element.  That template applies the formal.title.properties
attribute set.  So change:

parent::legalnotice

to

self::legalnotice

and it should work.

Most of the templates handling titles work with the container of the title
through most of the process.  That's largely because a given element's
title could come from more than one element, e.g.,  book/title or
book/info/title.

I don't know of a command line tool that reveals which templates are being
used.  If someone writes one, please let me know!  I generally use an XSL
debugger like Oxygen when I have to follow the template sequence.

Bob Stayton
Sagehill Enterprises
DocBook Consulting
bobs@sagehill.net
~spr

Re: Howto customize title for legalnotice

by Bob Stayton :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hmm, I cut and pasted your attribute-set into a simple customization layer
based on 1.73.2 fo/docbook.xsl, processed a short book with xsltproc and
fop 0.94, and it worked.  I also processed it with the fop shell script,
and that worked as well.  That is, the legalnotice title was rendered in
red on the verso titlepage, while other formal titles appeared in black.

Have you tried it with a minimal customization layer to see if something
else is affecting it?

Bob Stayton
Sagehill Enterprises
DocBook Consulting
bobs@...


----- Original Message -----
From: "spr" <spremi@...>
To: <docbook-apps@...>
Sent: Friday, October 05, 2007 3:39 AM
Subject: Re: [docbook-apps] Howto customize title for legalnotice


>
> Did not work :(
>
>  <xsl:attribute-set name="formal.title.properties">
>  <xsl:attribute name="color">
>    <xsl:choose>
>      <xsl:when test = "self::legalnotice">red</xsl:when>
>      <xsl:otherwise>black</xsl:otherwise>
>    </xsl:choose>
>  </xsl:attribute>
>
> Did try to go thru the fo/titlepage.xsl -> formal.object.heading ->
> formal.title.properties.
>
> I believe that it should have workerd, but like some other issues that I
> have posted, i am loosing faith the the 'fop'. Will setup and use
> standalone
> xslt processor and see if it makes difference.
>
> ~spr
>
>
> Hi,
> The test is failing because the context node is legalnotice, not
> legalnotice/title.  A legalnotice is handled by the template with
> match="legalnotice" and mode="titlepage.mode" in fo/titlepage.xsl.  It
> calls the formal.object.heading template, with the context still being
> the
> legalnotice element.  That template applies the formal.title.properties
> attribute set.  So change:
>
> parent::legalnotice
>
> to
>
> self::legalnotice
>
> and it should work.
>
> Most of the templates handling titles work with the container of the
> title
> through most of the process.  That's largely because a given element's
> title could come from more than one element, e.g.,  book/title or
> book/info/title.
>
> I don't know of a command line tool that reveals which templates are
> being
> used.  If someone writes one, please let me know!  I generally use an XSL
> debugger like Oxygen when I have to follow the template sequence.
>
> Bob Stayton
> Sagehill Enterprises
> DocBook Consulting
> bobs@...
>
> --
> View this message in context:
> http://www.nabble.com/Howto-customize-title-for-legalnotice-tf4568304.html#a13056929
> Sent from the docbook apps mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: docbook-apps-unsubscribe@...
> For additional commands, e-mail: docbook-apps-help@...
>
>
>



---------------------------------------------------------------------
To unsubscribe, e-mail: docbook-apps-unsubscribe@...
For additional commands, e-mail: docbook-apps-help@...


Re: Howto customize title for legalnotice

by spr :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I have only 20 lines of text in the test document.
Still haven't setup my PC for using xsltproc/saxon will do it tomorrow and get back...

~spr
Bob Stayton wrote:
Hmm, I cut and pasted your attribute-set into a simple customization layer
based on 1.73.2 fo/docbook.xsl, processed a short book with xsltproc and
fop 0.94, and it worked.  I also processed it with the fop shell script,
and that worked as well.  That is, the legalnotice title was rendered in
red on the verso titlepage, while other formal titles appeared in black.

Have you tried it with a minimal customization layer to see if something
else is affecting it?

Bob Stayton
Sagehill Enterprises
DocBook Consulting
bobs@sagehill.net
~spr

Re: Howto customize title for legalnotice

by spr :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Did not work either even with Saxon :(

I have attached the generated PDF.
See the green color on "Important Notice".
Used the "green" to ensure that customization is being processed.

~spr

My input XML is:
<?xml version='1.0'?>
<!DOCTYPE book PUBLIC
    "-//OASIS//DTD DocBook V5.0//EN"
    "file:///D:/wrk/BookTest/docbook-5.0CR5/dtd/docbook.dtd" [
<!ENTITY nbsp               " ">
]>

<book
  lang        = "en"
  xmlns       = "http://docbook.org/ns/docbook" version="5.0"test.pdf
  xmlns:xi    = "http://www.w3.org/2001/XInclude"
  xmlns:xsl   = "http://www.w3.org/1999/XSL/Transform"
  xmlns:xlink = "http://www.w3.org/1999/xlink">

  <info>
    <title>Book Title</title>
    <releaseinfo>Release Info</releaseinfo>

    <legalnotice>
      <title>IMPORTANT NOTICE</title>
      <para>
      This is a copyright text.
      </para>
    </legalnotice>
     
  </info>

  <chapter id="test">
    <info>
      <title>Test Chapter</title>
    </info>
    <para>
    simple test para
    </para>
  </chapter>
</book>

My minimal customization is:
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet
    xmlns:xsl   = "http://www.w3.org/1999/XSL/Transform"
    xmlns:fo    = "http://www.w3.org/1999/XSL/Format"
    xmlns:d     = "http://docbook.org/ns/docbook"
    version     = "5.0"
    xmlns:l     = "http://docbook.sourceforge.net/xmlns/l10n/1.0">

  <xsl:import
    href    = "../docbook-xsl-ns-1.73.2/fo/docbook.xsl" />

  <xsl:attribute-set name="formal.title.properties">
  <xsl:attribute name="color">
    <xsl:choose>
      <xsl:when test = "self::legalnotice">red</xsl:when>
      <xsl:otherwise>green</xsl:otherwise>
    </xsl:choose>
  </xsl:attribute>
  </xsl:attribute-set>

</xsl:stylesheet>

My execution log is:
D:\wrk\BookTest>xform-saxon.cmd CLASSPATH=D:\bin\JavaClasses\saxon6-5-5\saxon.jar;D:\bin\JavaClasses\saxon6-5-5\saxon-jdom.jar;D:\bin\JavaClasses\saxon6-5-5\saxon-xml-apis.jar;.\docbook-xsl-ns-1.73.2\extensions\saxon65.jar
java com.icl.saxon.StyleSheet -o .\output\test\test.fo .\input\test\index.xml .\custom\tst-pdf.xsl use.extensions=1
Making portrait pages on USletter paper (8.5inx11in)
.\fop-0.94\fop.bat -fo .\output\test\test.fo -pdf .\output\test\test.pdf
Oct 8, 2007 2:13:42 AM org.apache.fop.hyphenation.Hyphenator getHyphenationTree
SEVERE: Couldn't find hyphenation pattern en

D:\wrk\BookTest>

The extract from generated .fo is:
<fo:block space-before.optimum="1em" space-before.minimum="0.8em" space-before.maximum="1.2em" font-weight="bold" font-size="12pt" hyphenate="false" space-after.minimum="0.4em" space-after.optimum="0.6em" space-after.maximum="0.8em" color="green" keep-with-next.within-column="always">IMPORTANT NOTICE</fo:block><fo:block space-before.optimum="1em" space-before.minimum="0.8em" space-before.maximum="1.2em">
      This is a copyright text.
      </fo:block>


I have only 20 lines of text in the test document.
Still haven't setup my PC for using xsltproc/saxon will do it tomorrow and get back...

~spr
Bob Stayton wrote:
Hmm, I cut and pasted your attribute-set into a simple customization layer
based on 1.73.2 fo/docbook.xsl, processed a short book with xsltproc and
fop 0.94, and it worked.  I also processed it with the fop shell script,
and that worked as well.  That is, the legalnotice title was rendered in
red on the verso titlepage, while other formal titles appeared in black.

Have you tried it with a minimal customization layer to see if something
else is affecting it?

Bob Stayton
Sagehill Enterprises
DocBook Consulting
bobs@sagehill.net

~spr

RE: Howto customize title for legalnotice

by Mauritz Jeanson :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

> -----Original Message-----
> From: spr
>
> My minimal customization is:
> <?xml version="1.0" encoding="utf-8"?>
> <xsl:stylesheet
>     xmlns:xsl   = "http://www.w3.org/1999/XSL/Transform"
>     xmlns:fo    = "http://www.w3.org/1999/XSL/Format"
>     xmlns:d     = "http://docbook.org/ns/docbook"
>     version     = "5.0"
>     xmlns:l     = "http://docbook.sourceforge.net/xmlns/l10n/1.0">
>
>   <xsl:import
>     href    = "../docbook-xsl-ns-1.73.2/fo/docbook.xsl" />
>
>   <xsl:attribute-set name="formal.title.properties">
>   <xsl:attribute name="color">
>     <xsl:choose>
>       <xsl:when test = "self::legalnotice">red</xsl:when>
>       <xsl:otherwise>green</xsl:otherwise>
>     </xsl:choose>
>   </xsl:attribute>
>   </xsl:attribute-set>


Since you use the XSL-NS stylesheets, you must use

 <xsl:when test = "self::d:legalnotice">red</xsl:when>

And the value of the version attribute should be 1.0.

/MJ




---------------------------------------------------------------------
To unsubscribe, e-mail: docbook-apps-unsubscribe@...
For additional commands, e-mail: docbook-apps-help@...


RE: Howto customize title for legalnotice

by spr :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Sorry, made same mistake 2nd time within a week :(
Will be more careful now...

~spr

Mauritz Jeanson wrote:
> -----Original Message-----
> From: spr
>
> My minimal customization is:
> <?xml version="1.0" encoding="utf-8"?>
> <xsl:stylesheet
>     xmlns:xsl   = "http://www.w3.org/1999/XSL/Transform"
>     xmlns:fo    = "http://www.w3.org/1999/XSL/Format"
>     xmlns:d     = "http://docbook.org/ns/docbook"
>     version     = "5.0"
>     xmlns:l     = "http://docbook.sourceforge.net/xmlns/l10n/1.0">
>
>   <xsl:import
>     href    = "../docbook-xsl-ns-1.73.2/fo/docbook.xsl" />
>
>   <xsl:attribute-set name="formal.title.properties">
>   <xsl:attribute name="color">
>     <xsl:choose>
>       <xsl:when test = "self::legalnotice">red</xsl:when>
>       <xsl:otherwise>green</xsl:otherwise>
>     </xsl:choose>
>   </xsl:attribute>
>   </xsl:attribute-set>


Since you use the XSL-NS stylesheets, you must use

 <xsl:when test = "self::d:legalnotice">red</xsl:when>

And the value of the version attribute should be 1.0.

/MJ




---------------------------------------------------------------------
To unsubscribe, e-mail: docbook-apps-unsubscribe@lists.oasis-open.org
For additional commands, e-mail: docbook-apps-help@lists.oasis-open.org
~spr