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 "Lee, Insoo" <In...@gs.com> on 2003/09/03 19:54:09 UTC

RE: reading fo tags from database and using within xsl dynamicall y

Thanks Pietschmann for your reply.

I just wanted to be a bit more clear:

here is my xml input

<?xml version="1.0"?>
...
	<disclaimer>
		<fo:block font-weight="bold">
			This is dynamically generated
		</fo:block>

		<fo:block>
			This is dynamically generated
		</fo:block>
	</disclaimer>
...
</xml>


how can we have those fo tags have actual effects when we feed this xml to
transfomer?
rather than print out actual <fo:....  ?



Thanks


-----Original Message-----
From: J.Pietschmann [mailto:j3322ptm@yahoo.de]
Sent: Thursday, August 28, 2003 4:45 PM
To: fop-user@xml.apache.org
Subject: Re: reading fo tags from database and using within xsl
dynamically


Lee, Insoo wrote:
>   We need to read it a value dynamically from the database.
>   and this value contains fop tags such as
> 
>   <fo:block>
> 	blah blah blah
>   </fo:block>
...
>   Is there any way to display that within the xsl (this xsl contains other
> fop tags too)?

Yes.

>   We tried following
> 
>  <xsl:template match="DISCLAIMER">
>           <xsl:value-of select="."/>
>  </xsl:template>
> 
> we also tried  and xsl:copy-of
> 
>   and disable-output-escaping="yes"... but 
>   
>   none of them works...

Well, "not working" could mean a lot of things. Could you be
a bit more specific?

I guess you got "<fo:block>" literally in your result, or
nothing at all and an error message in the logs (like "text
must not be child of fo:flow"). You probably constructed a DOM
or something like this and inserted the strings retrieved from
the DB as text nodes, then feed this to the transformation.
The stuff retrieved from the DB stayed just that: text. You'll
have to parse them as XML in order to have them the effect you
want to have. How to do this depends on how you assemble your
source data. A semi-simple way is to construct the whole XML
as a string and pass it as a StreamSource reading from a
StringReader to the transformer.

J.Pietschmann


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

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


Re: reading fo tags from database and using within xsl dynamicall y

Posted by "J.Pietschmann" <j3...@yahoo.de>.
Lee, Insoo wrote:
> I just wanted to be a bit more clear:
> 
> here is my xml input
> 
> <?xml version="1.0"?>
> ...
> 	<disclaimer>
> 		<fo:block font-weight="bold">
> 			This is dynamically generated
> 		</fo:block>
> 
> 		<fo:block>
> 			This is dynamically generated
> 		</fo:block>
> 	</disclaimer>
> ...
> </xml>
> 
> how can we have those fo tags have actual effects when we feed this xml to
> transfomer?
> rather than print out actual <fo:....  ?

If the XML was actually a source *file* and processed as such, there
are no special things to do.
However, as I alreay wrote, I suspect you get this as *text*, rather
than *element nodes* into the transformation input, via whatever means
you choose not to mention here. You can verify this by dumping the
transformation output to a file instead of feeding it to FOP, unless
you use disable-output-escaping in the transformation you'll probably
see
  &lt;fo:block font-weight="bold"&gt;
or something similar instead of
  <fo:block font-weight="bold">
in the file.

Advice: read a good book about XML in order to understand the difference
between an XML file and XML APIs, or post a more comprehensive description
of your approach to dynamical source generation (including the relevant
Java code).

J.Pietschmann


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


RE: reading fo tags from database and using within xsl dynamically

Posted by "Andreas L. Delmelle" <a_...@pandora.be>.
> From: Lee, Insoo [mailto:Insoo.Lee@gs.com]

> here is my xml input
>
> <?xml version="1.0"?>
> ...
> 	<disclaimer>
> 		<fo:block font-weight="bold">
> 			This is dynamically generated
> 		</fo:block>
>
> 		<fo:block>
> 			This is dynamically generated
> 		</fo:block>
> 	</disclaimer>
> ...
> </xml>
>
>

Are the <fo:block>-tags really part of the dynamically generated data? (
After reading your first msg I was under the impression they were, but I'm
not so sure if I look closely at this snippet. )
If they aren't, perhaps it would be worthwile to add 2 templates to the xsl,
like so:

<xsl:template match="disclaimer-bold">
	<fo:block font-weight="bold">
		<xsl:value-of select="."/>
	</fo:block>
</xsl:template>

<xsl:template match="disclaimer">
	<fo:block>
		<xsl:value-of select="."/>
	</fo:block>
</xsl:template>

And of course, add the corresponding <xsl:apply-templates select="..."/> at
the appropriate place.

Then, change the original xml to:

<?xml version="1.0" encoding="..."?>
<xmlroot>
<disclaimer-bold>Dynamically generated data</disclaimer-bold>
<disclaimer>Dynamically generated data</disclaimer>
...
</xmlroot>

( Well, perhaps the tag-names could be improved a bit... ;) And even more
general <xsl:template>s could be defined with a param in an external xsl
which you could include, so you can use these <fo:block>-tags anywhere in
your xsl where you need to put some text-block in bold or normal
font-weight, just by using <xsl:call-template with-param="..."/> )

This should do the trick ( if I'm getting the right impression of what
you're trying to achieve, that is... )

Hope this helps,

Andreas Delmelle


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