Ecrion Software Inc. Homepage
Forum Home Forum Home > XF Designer > Generic Support
  New Posts New Posts RSS Feed: Interpreting HTML content
  FAQ FAQ  Forum Search   Register Register  Login Login

Interpreting HTML content

 Post Reply Post Reply
Author
Message / View First Unread Post
het_hs View Drop Down
Newbie
Newbie
Avatar

Joined: 21 Apr 2010
Location: Mumbai
Posts: 4
Post Options Post Options   Quote het_hs Quote  Post ReplyReply Direct Link To This Post Topic: Interpreting HTML content
    Posted: 21 Apr 2010 at 7:21am
How to intepret HTML content in xsl-fo designer?
 
I have a field which contains HTML tags inside the value and that HTML tags needs to be interepreted on xsl-fo side so it shows the formatted text as inputted by User.
There is a rich text control on .NET side which allows user to format the text and the is stored in database with HTML tags. The same needs to be interpreted on xsl-fo while rendering the output.
 
How can we do this?
 
Like this control does. It takes the query in formatted text. Now if I want to show this formatted text on report developed in xsl-fo how do I do that?
 
Thanks in advance.
Hetal
Back to Top
hugo View Drop Down
Newbie
Newbie


Joined: 01 Jul 2010
Location: Amsterdam, NL
Posts: 5
Post Options Post Options   Quote hugo Quote  Post ReplyReply Direct Link To This Post Posted: 01 Jul 2010 at 9:11am
I need this too. Is there already a solution for this?
Back to Top
radup View Drop Down
Admin Group
Admin Group
Avatar
Adminstrator

Joined: 19 May 2008
Posts: 90
Post Options Post Options   Quote radup Quote  Post ReplyReply Direct Link To This Post Posted: 18 Aug 2011 at 12:37pm
To  interpret HTML tags you need to define a custom xslt code. This can be done by using "Global XSLT Code" dialog. More information about using this dialog is available here  http://www.ecrion.com/products/xfdesigner/XFDesignerHelp/hidd_edit_raw_xslt.htm.
For example for  â€œb”  html tag you have the following xslt code:
<xsl:template match="b">
   <fo:inline font-weight="bold">
       <xsl:apply-templates/>
   </fo:inline>
</xsl:template>
After declaring the xslt code insert an xfd:field with the attribute apply-templates="true". The field xpath will be the xml element xpath that contains these HTML tags.
Should look something like this:
<xfd:field xpath="/doc" apply-templates="true"/>


Edited by radup - 18 Aug 2011 at 12:42pm
I'm happy when my mind is free and my senses are occupied.
Back to Top
JohanPotgieter View Drop Down
Newbie
Newbie
Avatar

Joined: 13 Dec 2011
Location: South Africa
Posts: 3
Post Options Post Options   Quote JohanPotgieter Quote  Post ReplyReply Direct Link To This Post Posted: 13 Dec 2011 at 4:11am
I have tried this on a section with this text:
<b><div align="left"><font face="trebuchet ms" size="3">Replacement value condition</font></div></b>

and it had no effect. my xfd:field looked like this:
<xfd:field xpath="SPEC.TEXT" fo:id="582A6B21" fo:font-family="Arial" fo:font-size="9pt" apply-templates="true"/>

with SPEC.TEXT being the field to contain the html. Any help will be appreciated.
Back to Top
radup View Drop Down
Admin Group
Admin Group
Avatar
Adminstrator

Joined: 19 May 2008
Posts: 90
Post Options Post Options   Quote radup Quote  Post ReplyReply Direct Link To This Post Posted: 13 Dec 2011 at 6:53am
Hi Johan,

You need to define in Global XSLT a template match for each html tag occurred in your xml. 
For example you will need to define an interpretation for div tag, font tag etc.:
<xsl:template match="b">
   <fo:inline font-weight="bold">
<xsl:call-template name="ApplyAttributes"/>
<xsl:apply-templates/>
   </fo:inline>
</xsl:template>

<xsl:template match="i">
   <fo:inline font-style="italic">
<xsl:call-template name="ApplyAttributes"/>
<xsl:apply-templates/>
   </fo:inline>
</xsl:template>

<xsl:template match="font">
<fo:inline>
<xsl:call-template name="ApplyAttributes"/>
<xsl:apply-templates/>
</fo:inline>
</xsl:template>

<xsl:template match="div">
   <fo:block>
<xsl:call-template name="ApplyAttributes"/>
<xsl:apply-templates/>
   </fo:block>
</xsl:template>

<xsl:template name="ApplyAttributes">
<xsl:if test="@align">
<xsl:attribute name="text-align"><xsl:value-of select="@align"/></xsl:attribute>
</xsl:if>
<xsl:if test="@face">
<xsl:attribute name="font-family"><xsl:value-of select="@face"/></xsl:attribute>
</xsl:if>
<xsl:if test="@face">
<xsl:attribute name="font-size">
<xsl:choose>
 <xsl:when test="@size = 1">x-small</xsl:when>
 <xsl:when test="@size = 2">small</xsl:when>
 <xsl:when test="@size = 3">medium</xsl:when>
 <xsl:when test="@size = 4">large</xsl:when>
 <xsl:when test="@size &gt;= 5">x-large</xsl:when>
</xsl:choose>
 </xsl:attribute>
</xsl:if>
</xsl:template>

Regards,
Radu
Back to Top
JohanPotgieter View Drop Down
Newbie
Newbie
Avatar

Joined: 13 Dec 2011
Location: South Africa
Posts: 3
Post Options Post Options   Quote JohanPotgieter Quote  Post ReplyReply Direct Link To This Post Posted: 15 Dec 2011 at 2:58am
Hi there,

I must be missing something here. I have added the XSLT to "Review -> Global XSL. I also added apply-templates="true" to the xfd:field containing the html. When I generate the pdf or print layout the html tags are still there. What am I missing here?

regards,
Johan
Back to Top
justinw View Drop Down
Admin Group
Admin Group
Avatar

Joined: 08 Dec 2011
Posts: 199
Post Options Post Options   Quote justinw Quote  Post ReplyReply Direct Link To This Post Posted: 11 Apr 2013 at 12:29pm
In 2012 we added simplified functionality for accomplishing these goals of HTML tag inclusion. As this thread suggests, previously this was accomplished only by using Global XSLT. Based on a recurring need from our customers, we added a simple feature.  

Now you only need to drag your element containing the HTML into the Design Surface.  When you release the mouse button, you will need to select "HTML Field" from the contextual menu that will appear.  

For more about this useful feature, you can access the XF Designer product manual using this link:


Edited by justinw - 11 Apr 2013 at 12:34pm
Back to Top
Harry View Drop Down
Newbie
Newbie


Joined: 13 Jun 2013
Location: Raleigh
Posts: 1
Post Options Post Options   Quote Harry Quote  Post ReplyReply Direct Link To This Post Posted: 13 Jun 2013 at 2:20pm
Hello,

The HTML Filed option you described here does not work when you have HTML content inside the "Value" field of the XML.  It will work when your XML itself is generated from HTML, but if you have HTML formatting in the "value" field, how can I retain the formatting in the output?

Here is an example of my XML:  (I deleted lot of text for ease of reading)

        <Description typeid="2" value="&lt;p style=&quot;font:13px/19.18px sans-serif;margin:0.4em 0px 0.5em;color:#000000;text-transform:none;text-indent:0px;letter-spacing:normal;word-spacing:0px;white-space:normal;background-color:#ffffff;-webkit-text-stroke-width:0px;&quot;&gt;&lt;strong&gt;Trigonometry&lt;/strong&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;(from&lt;span class=&quot;Apple-converted- itle=&quot;Precalculus&quot;&gt;precalculus&lt;/a&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;course. &lt;/p&gt;" />

As you can see, my Description node has two attributes - type and Value.  The "Value" attribute has HTML text.  When I print it on report, how can I retain the formatting?

Back to Top
justinw View Drop Down
Admin Group
Admin Group
Avatar

Joined: 08 Dec 2011
Posts: 199
Post Options Post Options   Quote justinw Quote  Post ReplyReply Direct Link To This Post Posted: 13 Jun 2013 at 3:53pm
Hello Harry,

Thanks for reaching out to us.  Can you send your input XML to support@ecrion.com for a closer look to see if we can find an alternative?  This feature is structured to read HTML represented as nodes but not contained within one attribute's value.  As an example:

<html typeid="2">
<div align="left">
<font size="13px" face="Sans Serif">Trigonometry</font>
</div>
</html> 

HTML tags are not accepted inside attribute values. You need to insert the HTML structure at the XML node level:

<HTML content>
                <p>Some text</p>
                [……..]
</HTML content>


The transformations for HTML fields are executed internally with the help of an XSL template. The <xsl:template> elements used for HTML specific formatting cannot match XML nodes from within an XML attribute.


Edited by justinw - 14 Jun 2013 at 12:13pm
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Bulletin Board Software by Web Wiz Forums® version 9.69
Copyright ©2001-2010 Web Wiz

This page was generated in 0.078 seconds.