You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-dev@xmlgraphics.apache.org by Ch...@GIquadrat.de on 2000/07/25 13:39:10 UTC

stupid question: two elements on one line?

Hi,

I'm very new to this stuff,
I played around for a few days and I'm really impressed.
Right now I am trying to setup a demo to produce pdf output.

I have a problem and I don't even know if it's fo- or xsl-related :-(

Lets say I have to elements:

<firstname>
     Firstname
</firstname>

<lastname>
     Lastname
</lastname>

which I would like to put on one line seperated by a blank.

When I use:

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

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

I get (of course) 2 lines.

When I try something like:

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

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

Xalan does not like it.

Do I have use some fo:block parameters or how can I achive my goal?

Please excuse me, I know this is a dev list, but I read
in the archive about friendly people :-)

Thanks
Chris


RE: stupid question: two elements on one line?

Posted by Ronald Walraven <RW...@nl.alpnet.com>.
Christian,

Do as followed:
  <xsl:template match="firstname">
    <fo:block>
        <xsl:value-of select=".">
        <xsl:text> </xsl:text>
	  <xsl:value-of select="following-sibling::lastname[1]/>
    </fo:block>
  </xsl:template>

  <xsl:template match="lastname">
 	<!-- Do nothing -->
  </xsl:template>

This is not tested.

Ideally, and more elegant, you would have wrapper element around 'firstname'
and 'lastname'. Something like:
<name>
  <firstname>
    Firstname
  </firstname>
  <lastname>
    Lastname
  </lastname>
</name>

Than you could do:
<xsl:template match="firstname">
  <fo:block>
      <xsl:value-of select="firstname"/>
	<xsl:text> </xsl:text>
	<xsl:value-of select="lastname"/>
  </fo:block>
</xsl:template>

Hope this helps,

Regards,

Ronald

-----Original Message-----
From: Christian.Menzel@GIquadrat.de
[mailto:Christian.Menzel@GIquadrat.de]
Sent: dinsdag 25 juli 2000 13:39
To: fop-dev@xml.apache.org
Subject: stupid question: two elements on one line?


Hi,

I'm very new to this stuff,
I played around for a few days and I'm really impressed.
Right now I am trying to setup a demo to produce pdf output.

I have a problem and I don't even know if it's fo- or xsl-related :-(

Lets say I have to elements:

<firstname>
     Firstname
</firstname>

<lastname>
     Lastname
</lastname>

which I would like to put on one line seperated by a blank.

When I use:

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

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

I get (of course) 2 lines.

When I try something like:

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

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

Xalan does not like it.

Do I have use some fo:block parameters or how can I achive my goal?

Please excuse me, I know this is a dev list, but I read
in the archive about friendly people :-)

Thanks
Chris