docbook-apps

  • 1.  RE: [docbook-apps] Equation alignment

    Posted 10-25-2007 13:19
    Mauritz
    Thanks for the template. But I am a bit confused about how to apply the implementation.

    The code in my doc is like this:

    <equation>
    <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="e5-math-zr-basic.xml"/>
    </equation>

    and the included file is:




    "http://www.w3.org/TR/MathML2/dtd/mathml2.dtd" [


    ]>
    <mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML" id="mymath">

    <mml:mrow>
    <mml:mn>Z</mml:mn>
    <mml:mo>=</mml:mo>
    <mml:mn>a</mml:mn>
    <mml:msup><mml:mi>R</mml:mi><mml:mn>b</mml:mn></mml:msup>
    </mml:mrow>
    </mml:math>


    However, the formula shows up left aligned and I need it centered. So how do I specify the "alignment" when using your template?


    I am using SAXON and FOP 0.94.


    Dean




    -----Original Message-----
    From: Mauritz Jeanson [mailto:mj@johanneberg.com]
    Sent: Wed 10/24/2007 12:12 PM
    To: Nelson, Dean; docbook-apps@lists.oasis-open.org
    Subject: RE: [docbook-apps] Equation alignment

    > -----Original Message-----
    > From: Nelson, Dean
    >
    > Does anyone know how to align a MathML equation on the page?
    > I am using the equation tag, but there is no horizontal
    > alignment feature. In the past, I used graphics via the
    > mediaobject and they are aligned in the imagedata. But when
    > using MathML there is no such feature.
    >
    > Any ideas?


    The current stylesheets are not very sophisticated. The MathML markup gets
    through to the output, but that's about it.

    The following customization adds support for @align and @valign on imagedata
    (the original template is in math.xsl):

    <xsl:template match="mml:math"
    xmlns:mml="http://www.w3.org/1998/Math/MathML">
    <xsl:choose>


    <xsl:when test="not($passivetex.extensions = 0)">
    <xsl:copy>
    <xsl:copy-of select="@*"/>
    <xsl:apply-templates/>
    </xsl:copy>
    </xsl:when>
    <xsl:otherwise>
    <fo:instream-foreign-object>


    <xsl:if test="../@align">
    <xsl:attribute name="text-align">
    <xsl:value-of select="../@align"/>
    </xsl:attribute>
    </xsl:if>

    <xsl:if test="../@valign">
    <xsl:attribute name="display-align">
    <xsl:choose>
    <xsl:when test="../@valign = 'top'">before</xsl:when>
    <xsl:when test="../@valign = 'middle'">center</xsl:when>
    <xsl:when test="../@valign = 'bottom'">after</xsl:when>
    <xsl:otherwise>auto</xsl:otherwise>
    </xsl:choose>
    </xsl:attribute>
    </xsl:if>


    <xsl:copy>
    <xsl:copy-of select="@*"/>
    <xsl:apply-templates/>
    </xsl:copy>
    </fo:instream-foreign-object>
    </xsl:otherwise>
    </xsl:choose>
    </xsl:template>

    I'm not sure if this is the way to go in the long run. I guess that it would
    be better if the process.image template in graphics.xsl could be reworked so
    that it also supports imagedata attributes for MathML (and SVG).

    /Mauritz







  • 2.  RE: [docbook-apps] Equation alignment

    Posted 10-25-2007 15:27
    > -----Original Message-----
    > From: Nelson, Dean

    > Mauritz
    > Thanks for the template. But I am a bit confused about how to
    > apply the implementation.
    >
    > The code in my doc is like this:
    >
    > <equation>
    > <xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
    > href="e5-math-zr-basic.xml"/>
    > </equation>

    > However, the formula shows up left aligned and I need it
    > centered. So how do I specify the "alignment" when using your
    > template?


    I'm sorry if I was unclear. The customization I sent only applies to MathML
    content in imagedata, because that element has align and valign attributes.

    The equation, inlineequation, and informalequation elements don't have any
    alignment attributes. Therefore the customization does not work if you have
    MathML as a direct child of any of these elements.

    You can have mediaobject/imageobject/imagedata inside equation. This should
    work:

    <equation>
    <mediaobject>
    <imageobject>
    <imagedata align="center">
    <mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML"
    id="mymath">
    <mml:mrow>
    <mml:mn>Z</mml:mn>
    <mml:mo>=</mml:mo>
    <mml:mn>a</mml:mn>
    <mml:msup><mml:mi>R</mml:mi><mml:mn>b</mml:mn></mml:msup>
    </mml:mrow>
    </mml:math>
    </imagedata>
    </imageobject>
    </mediaobject>
    </equation>

    Mauritz





  • 3.  RE: [docbook-apps] Equation alignment

    Posted 10-25-2007 15:47
    Mauritz
    I see now the logic of where you activate the code.

    However, when using your template in my customization layer, the image
    does not show up because imagedata is looking for a graphic file.

    Also, I did not see anything in the template tying it to imagedata. Did
    I miss something?

    Regards,

    Dean Nelson
    Enterprise Electronics Corp




    -----Original Message-----
    From: Mauritz Jeanson [mailto:mj@johanneberg.com]
    Sent: Thursday, October 25, 2007 10:27 AM
    To: Nelson, Dean
    Cc: docbook-apps@lists.oasis-open.org
    Subject: RE: [docbook-apps] Equation alignment


    > -----Original Message-----
    > From: Nelson, Dean

    > Mauritz
    > Thanks for the template. But I am a bit confused about how to
    > apply the implementation.
    >
    > The code in my doc is like this:
    >
    > <equation>
    > <xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
    > href="e5-math-zr-basic.xml"/>
    > </equation>

    > However, the formula shows up left aligned and I need it
    > centered. So how do I specify the "alignment" when using your
    > template?


    I'm sorry if I was unclear. The customization I sent only applies to
    MathML
    content in imagedata, because that element has align and valign
    attributes.

    The equation, inlineequation, and informalequation elements don't have
    any
    alignment attributes. Therefore the customization does not work if you
    have
    MathML as a direct child of any of these elements.

    You can have mediaobject/imageobject/imagedata inside equation. This
    should
    work:

    <equation>
    <mediaobject>
    <imageobject>
    <imagedata align="center">
    <mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML"
    id="mymath">
    <mml:mrow>
    <mml:mn>Z</mml:mn>
    <mml:mo>=</mml:mo>
    <mml:mn>a</mml:mn>
    <mml:msup><mml:mi>R</mml:mi><mml:mn>b</mml:mn></mml:msup>
    </mml:mrow>
    </mml:math>
    </imagedata>
    </imageobject>
    </mediaobject>
    </equation>

    Mauritz





  • 4.  RE: [docbook-apps] Equation alignment

    Posted 10-25-2007 17:29
    > -----Original Message-----
    > From: Nelson, Dean
    >
    > However, when using your template in my customization layer, the image
    > does not show up because imagedata is looking for a graphic file.
    >
    > Also, I did not see anything in the template tying it to
    > imagedata. Did
    > I miss something?


    Dean,

    I forgot to mention that you must use a recent snapshot release. I checked
    in the update to handle MathML in imagedata (in graphics.xsl) on 13 October.
    Please accept my apologies for not giving you the whole story.

    Mauritz





  • 5.  RE: [docbook-apps] Equation alignment

    Posted 10-25-2007 18:12
    Wow - state-of-the-art service!

    Thanks, I'll check it out.

    Regards,

    Dean Nelson
    Enterprise Electronics Corp




    -----Original Message-----
    From: Mauritz Jeanson [mailto:mj@johanneberg.com]
    Sent: Thursday, October 25, 2007 12:29 PM
    To: Nelson, Dean
    Cc: docbook-apps@lists.oasis-open.org
    Subject: RE: [docbook-apps] Equation alignment


    > -----Original Message-----
    > From: Nelson, Dean
    >
    > However, when using your template in my customization layer, the image

    > does not show up because imagedata is looking for a graphic file.
    >
    > Also, I did not see anything in the template tying it to
    > imagedata. Did
    > I miss something?


    Dean,

    I forgot to mention that you must use a recent snapshot release. I
    checked
    in the update to handle MathML in imagedata (in graphics.xsl) on 13
    October.
    Please accept my apologies for not giving you the whole story.

    Mauritz





  • 6.  RE: [docbook-apps] Equation alignment

    Posted 10-25-2007 18:32
    Mauritz

    It works as advertized! Thanks.

    Also, is there a quick way to align the equation titles in the same
    manner? The title tag doesn't have an align property?

    Regards,

    Dean Nelson
    Enterprise Electronics Corp




    -----Original Message-----
    From: Mauritz Jeanson [mailto:mj@johanneberg.com]
    Sent: Thursday, October 25, 2007 12:29 PM
    To: Nelson, Dean
    Cc: docbook-apps@lists.oasis-open.org
    Subject: RE: [docbook-apps] Equation alignment


    > -----Original Message-----
    > From: Nelson, Dean
    >
    > However, when using your template in my customization layer, the image

    > does not show up because imagedata is looking for a graphic file.
    >
    > Also, I did not see anything in the template tying it to
    > imagedata. Did
    > I miss something?


    Dean,

    I forgot to mention that you must use a recent snapshot release. I
    checked
    in the update to handle MathML in imagedata (in graphics.xsl) on 13
    October.
    Please accept my apologies for not giving you the whole story.

    Mauritz





  • 7.  RE: [docbook-apps] Equation alignment

    Posted 10-26-2007 15:13
    > -----Original Message-----
    > From: Nelson, Dean
    >
    > Also, is there a quick way to align the equation titles in the same
    > manner? The title tag doesn't have an align property?


    You can customize the formal.title.properties attribute-set in order to
    apply the align attribute to the equation title:

    <xsl:attribute-set name="formal.title.properties"
    use-attribute-sets="normal.para.spacing">
    <xsl:attribute name="text-align">
    <xsl:choose>
    <xsl:when test="self::equation and descendant::imagedata/@align">
    <xsl:value-of select="descendant::imagedata/@align"/>
    </xsl:when>
    <xsl:otherwise>start</xsl:otherwise>
    </xsl:choose>
    </xsl:attribute>
    </xsl:attribute-set>

    Mauritz





  • 8.  RE: [docbook-apps] Equation alignment

    Posted 10-26-2007 20:17
    Nice, thanks!

    Regards,

    Dean Nelson
    Enterprise Electronics Corp




    -----Original Message-----
    From: Mauritz Jeanson [mailto:mj@johanneberg.com]
    Sent: Friday, October 26, 2007 10:13 AM
    To: Nelson, Dean
    Cc: docbook-apps@lists.oasis-open.org
    Subject: RE: [docbook-apps] Equation alignment


    > -----Original Message-----
    > From: Nelson, Dean
    >
    > Also, is there a quick way to align the equation titles in the same
    > manner? The title tag doesn't have an align property?


    You can customize the formal.title.properties attribute-set in order to
    apply the align attribute to the equation title:

    <xsl:attribute-set name="formal.title.properties"
    use-attribute-sets="normal.para.spacing">
    <xsl:attribute name="text-align">
    <xsl:choose>
    <xsl:when test="self::equation and descendant::imagedata/@align">
    <xsl:value-of select="descendant::imagedata/@align"/>
    </xsl:when>
    <xsl:otherwise>start</xsl:otherwise>
    </xsl:choose>
    </xsl:attribute>
    </xsl:attribute-set>

    Mauritz