You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-users@xmlgraphics.apache.org by "Forest, Sebastien" <Se...@L-3Com.com> on 2004/02/02 19:20:06 UTC

RE: Change page size

> Forest, Sebastien wrote:
> > Hi
> > I need to produce a pdf with fop 0.20.5rc3a with a combinaison of two 
> > differents page size. The document is in 8.5 X 11 inch but when I 
> > encounter a special tag in the xml file I need to switch to 11 X 17 
> > inch. Is there a way to switch page-master depending on the tag in the
> xml.
> 
> Create a new page-sequence when you encounter the tag thats orders a 
> change in page dimensions. Of course, this will cause text after the tag 
> to be moved to a new page.
> 
When I encounter the tag I create a new page-sequence but FOP give me an
error because the page-sequence must be in the fo:root and not in a
fo:block. I'am able to change page-sequence, but only if the tag I'm looking
for is at the root. If this tag ("graphic" in my example) is a child of
another tag I didn't find a way to control it.

Exemple:
<?xml version="1.0" encoding="UTF-8"?>
<wp>
  <para>para 1
    <para>para 1.1</para>
  </para>
  <para>para 2</para>
  <para>para 3</para>
  <graphic>graphic 1</graphic>
  <para>para 4</para>
  <graphic>graphic 2</graphic>
  <graphic>graphic 3</graphic>
  <para>para 5
    <para>para 5.1
      <graphic>graphic 4</graphic>
    </para>
  </para>
</wp>

Can anyone help me?


Re: Change page size

Posted by "J.Pietschmann" <j3...@yahoo.de>.
Forest, Sebastien wrote:
> When I encounter the tag I create a new page-sequence but FOP give me an
> error because the page-sequence must be in the fo:root and not in a
> fo:block. I'am able to change page-sequence, but only if the tag I'm looking
> for is at the root. If this tag ("graphic" in my example) is a child of
> another tag I didn't find a way to control it.

You need to look into grouping techniques in order to
sort of "pull the special tag to the top level". It's
somewhat hairrising though.

J.Pietschmann

---------------------------------------------------------------------
To unsubscribe, e-mail: fop-user-unsubscribe@xml.apache.org
For additional commands, e-mail: fop-user-help@xml.apache.org


RE: Change page size

Posted by "Andreas L. Delmelle" <a_...@pandora.be>.
> -----Original Message-----
> From: Forest, Sebastien [mailto:Sebastien.Forest@L-3Com.com]

> Hi

Hi

Some friendly advice to start:
Would you be so kind the next time, to post in plain-text? Not a problem for
me specifically, but some would find it a reason to ignore your question if
you don't... Just imagine for a moment what all that HTML looks like in
plain text view.

Now as to your question:
> When I encounter the tag I create a new page-sequence but FOP give me an
error
> because the page-sequence must be in the fo:root and not in a fo:block.
> I'am able to change page-sequence, but only if the tag I'm looking for is
at
> the root. If this tag ("graphic" in my example) is a child of another tag
I
> didn't find a way to control it.

I think you're going to need three XSL templates for this:
(more of a Mulberry-question, come to think of it)

- one for the plain <para .../> elements (sans graphiques ;) )
- one for the <graphic .../> elements that are children of the root
- one to handle <graphic /> elements with <para .../> ancestors

Example stylesheet:

<?xml version="1.0" encoding="iso-8859-1" ?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" />

<xsl:template match="wp">
  <foroot>
    <xsl:apply-templates select="para[not(descendant::graphic)]
                                 | //graphic" />
  </foroot>
</xsl:template>

<xsl:template match="para[not(descendant::graphic)]">
  <xsl:choose>
  <xsl:when test="parent::wp">
    <fopageseq ref="a">
      <foblock>
        <xsl:apply-templates />
      </foblock>
    </fopageseq>
  </xsl:when>
  <xsl:otherwise>
    <foblock>
      <xsl:apply-templates />
    </foblock>
  </xsl:otherwise>
  </xsl:choose>
</xsl:template>

<xsl:template match="graphic[parent::wp]">
  <fopageseq ref="b">
    <foextgraph src="{.}" />
  </fopageseq>
</xsl:template>

<xsl:template match="graphic[ancestor::para]">
  <fopageseq ref="a">
    <xsl:for-each select="ancestor::para">
      <xsl:sort select="position()" order="ascending" />
        <foblock>
          <xsl:value-of select="text()" />
        </foblock>
    </xsl:for-each>
  </fopageseq>
  <fopageseq ref="b">
    <foextgraph src="{.}" />
  </fopageseq>

</xsl:template>

</xsl:stylesheet>

Modify this to use real fo's, and use it to transform your example XML. Only
case not handled by the above template is: a <para> that would be following
'graphic 4' in your example, but would still be a child of the 'para 5'
node... Just to give you an idea.


Cheers,

Andreas


---------------------------------------------------------------------
To unsubscribe, e-mail: fop-user-unsubscribe@xml.apache.org
For additional commands, e-mail: fop-user-help@xml.apache.org