List Info

Thread: Best way to implement author-specified keep-with-next options?




Best way to implement author-specified keep-with-next options?
user name
2007-07-25 17:06:32
Hello!

    In the document I'm working on, I'm finding a need to
specify the
keep-with-next option in several places.  Since docbook-xsl
1.73.0
doesn't seem to provide this by itself, I came up with the
following
simplistic approach.  Is this the "right" way to
do things?

<!-- ---------------- in FO customization layer:
---------------- -->
    <!--
        Custom processing instruction target:  NeoBook
    -->
    <xsl:template
match="processing-instruction('NeoBook')">
        <xsl:variable
name="keep.with.next">
            <xsl:call-template
name="pi-attribute">
                <xsl:with-param name="pis"
select="." />
                <xsl:with-param
name="attribute"
select="'keep-with-next'" />
            </xsl:call-template>
        </xsl:variable> 
        <xsl:if test="$keep.with.next !=
''">
            <xsl:attribute
name="keep-with-next.within-column">
                <xsl:value-of
select="$keep.with.next" />
            </xsl:attribute>
        </xsl:if>
    </xsl:template>

<!-- ---------------- in document: ----------------
-->

    <para><?NeoBook
keep-with-next="always"?>
        text of paragraph goes here
    </para>
    <para>
        The previous paragraph will always be kept
        with this paragraph.
    </para>

<!-- ---------------- ---------------- -->

Thanks in advance!
- Johnson


       
____________________________________________________________
________________________
Be a better Globetrotter. Get better travel answers from
someone who knows. Yahoo! Answers - Check it out.
http://answers.yahoo.com/dir/?link=list&sid=3965454
69

------------------------------------------------------------
---------
To unsubscribe, e-mail: docbook-apps-unsubscribelists.oasis-open.org
For additional commands, e-mail: docbook-apps-helplists.oasis-open.org


Re: Best way to implement author-specified keep-with-next options?
user name
2007-07-27 11:21:04
Hi,
I think you will find that your solution works in some
locations but not 
others.  Since the PI generates an <xsl:attribute>
element, it must be 
processed right after an output element is opened but before
any content is 
added to it.  In your para example it will work, but most
likely in other 
places it will generate an error message and not work
because the template 
already generated some content before it does
xsl:apply-templates (which 
triggers the processing of the PI).

I don't think there is a general solution for using a
processing 
instruction to insert a keep (or any other) property.  But
if it works in 
the situations you need, then your implementation is fine.

Bob Stayton
Sagehill Enterprises
DocBook Consulting
bobssagehill.net


----- Original Message ----- 
From: "Johnson Earls" <darkfoxprimeyahoo.com>
To: <docbook-appslists.oasis-open.org>
Sent: Wednesday, July 25, 2007 3:06 PM
Subject: [docbook-apps] Best way to implement
author-specified 
keep-with-next options?


> Hello!
>
>    In the document I'm working on, I'm finding a need
to specify the
> keep-with-next option in several places.  Since
docbook-xsl 1.73.0
> doesn't seem to provide this by itself, I came up with
the following
> simplistic approach.  Is this the "right" way
to do things?
>
> <!-- ---------------- in FO customization layer:
---------------- -->
>    <!--
>        Custom processing instruction target:  NeoBook
>    -->
>    <xsl:template
match="processing-instruction('NeoBook')">
>        <xsl:variable
name="keep.with.next">
>            <xsl:call-template
name="pi-attribute">
>                <xsl:with-param name="pis"
select="." />
>                <xsl:with-param
name="attribute"
> select="'keep-with-next'" />
>            </xsl:call-template>
>        </xsl:variable>
>        <xsl:if test="$keep.with.next !=
''">
>            <xsl:attribute
name="keep-with-next.within-column">
>                <xsl:value-of
select="$keep.with.next" />
>            </xsl:attribute>
>        </xsl:if>
>    </xsl:template>
>
> <!-- ---------------- in document: ----------------
-->
>
>    <para><?NeoBook
keep-with-next="always"?>
>        text of paragraph goes here
>    </para>
>    <para>
>        The previous paragraph will always be kept
>        with this paragraph.
>    </para>
>
> <!-- ---------------- ---------------- -->
>
> Thanks in advance!
> - Johnson
>
>
>
>
____________________________________________________________
________________________
> Be a better Globetrotter. Get better travel answers
from someone who 
> knows. Yahoo! Answers - Check it out.
> http://answers.yahoo.com/dir/?link=list&sid=3965454
69
>
>
------------------------------------------------------------
---------
> To unsubscribe, e-mail: docbook-apps-unsubscribelists.oasis-open.org
> For additional commands, e-mail: docbook-apps-helplists.oasis-open.org
>
>
> 



------------------------------------------------------------
---------
To unsubscribe, e-mail: docbook-apps-unsubscribelists.oasis-open.org
For additional commands, e-mail: docbook-apps-helplists.oasis-open.org


[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )