Re: Dynamically insert SVG graphics in the XML passed to FOP
"Szeak (Register Man)" <[email protected]>
| Newsgroups | gmane.text.xml.fop.user |
|---|---|
| Message-ID | <[email protected]> |
Hi,
<xsl:copy-of select="svgDynamique/*"/>
may select nodes only under svgDynamique element, and not svgDynamique
itself. If don't work try:
<xsl:copy-of select="//svgDynamique"/>
or
<xsl:copy-of select="//svgDynamique|svgDynamique/*"/>
Best regards, szeak
2017-06-26 12:41 keltezéssel, Matthias Reischenbacher írta:
> Hi,
>
> On 24.06.2017 00:50, Pierre Caron wrote:
>> Thank you Matthias. I was able to generate valid SVG code with this :
>>
>> handler.startElement("svgDynamique");
>> handler.startElement("http://www.w3.org/2000/svg", "svg", "svg
>> width=\"20\" height=\"20\"", EMPTY_ATTS);
>> handler.startElement("g style=\"fill:red; stroke:#000000\"");
> Don't use handler.startElement witout specifying a namespace and the
> attributes (such as "style") should be specified as last parameter of
> the startElement method call.
>> handler.element("rect x=\"0\" y=\"0\" width=\"15\"
>> height=\"15\"", "");
>> handler.element("rect x=\"5\" y=\"5\" width=\"15\"
>> height=\"15\"", "");
> Same here. Use startElement with namespace and fix attribute.
>> handler.endElement("g");
>> handler.endElement("http://www.w3.org/2000/svg", "svg", "svg");
>> handler.endElement("svgDynamique");
>>
>> which yielded :
>>
>> <svgDynamique>
>> <svg width="20" height="20" xmlns="http://www.w3.org/2000/svg">
>> <g style="fill:red; stroke:#000000">
>> <rect x="0" y="0" width="15" height="15"/>
>> <rect x="5" y="5" width="15" height="15"/>
>> </g>
>> </svg>
>> </svgDynamique>
>>
>> Now, the problem is inserting this code in the fo template. I have tried
>> the following :
>>
>> <fo:table-cell border-width="0.25mm" border-style="solid">
>> <fo:block space-before.optimum="15pt">
>> <fo:instream-foreign-object>
>> <xsl:value-of select="svgDynamique"
>> disable-output-escaping="yes" />
>> </fo:instream-foreign-object>]
>> </fo:block>
>> </fo:table-cell>
>>
>> but I get the following message which suggest that the SVG code isn't
>> present :
>>
>> org.apache.fop.fo.ValidationException: "fo:instream-foreign-object" is
>> missing child elements. Required content model: one (1) non-XSL namespace
>> child (No context info available)
>>
>> I have also tried without success either :
>>
>> <xsl:copy-of select="svgDynamique" />
> <xsl:copy-of select="svgDynamique/*"/> should work.
>> My second question is : if the SVG is generated through Batik, how do you
>> embed it in the fo file?
> You will need to parse the SVG file and insert it into the FO file via
> DOM operations or you use the fo:external-graphic element and specify as
> source the SVG file.
>
> Best regards,
> Matthias
>
>> Again, thank you very much!
>>
>>
>>
>> --
>> View this message in context: http://apache-fop.1065347.n5.nabble.com/Dynamically-insert-SVG-graphics-in-the-XML-passed-to-FOP-tp45237p45239.html
>> Sent from the FOP - Users mailing list archive at Nabble.com.
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [email protected]
>> For additional commands, e-mail: [email protected]
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>