0 Replies Latest reply: May 15, 2013 5:20 AM by 962123 RSS

    Creating Hyperlinks from XML

    962123
      Hi ,
      Can one of you give me some guidance on how to create hyperlinks through xml file. My requirement is to create an PDF template from an XML and XLS stylesheet, in which certain superscript fields i want to create
      the hyperlinks. i have tried out somewhat in the below XLS for template name as Superscript, i was succesful in getting change the colour, but i was not able to make the superscript fields act as hyperlinks.
      Guys, this is a bit urgent and thanks in advance for your suggestions.

      <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" >
      <xsl:output method="xml" encoding="%%ENCODING%%" cdata-section-elements="string"/>
      <xsl:param name="x-offset">2</xsl:param>
      <xsl:param name="supx-offset">0</xsl:param>
      <xsl:param name="y-offset">-4</xsl:param>
      <xsl:param name="m_factor">0.25</xsl:param>
      <xsl:param name="c_factor">0.5</xsl:param>
      <xsl:param name="sup-display-width">15</xsl:param>
      <xsl:param name="sup-display-height">8</xsl:param>
      <xsl:param name="clearanceBuffer">2</xsl:param>
      <xsl:param name="Buffer">2</xsl:param>
      <xsl:param name="little_push">2</xsl:param>
      <xsl:param name="RdciFontFace"/>
      <xsl:param name="nPageHeight"/>
      <xsl:param name="nPageWidth"/>
      <xsl:param name="nFLHeight"/>
      <xsl:param name="nFLWidth"/>
      <xsl:param name="IncrementY"/>
      <xsl:param name="IncrementX"/>

      <xsl:template match="node() | @*">
      <xsl:copy>
      <xsl:apply-templates select="@* | node()"/>
      </xsl:copy>
      <xsl:if test="local-name()='frame'">
      <xsl:for-each select="formField">
      <xsl:sort order="ascending" select="@name"/>
      <xsl:if test="not(./@name = preceding-sibling::node()/@name)">
      <xsl:call-template name="Superscript"/>
      </xsl:if>
      </xsl:for-each>
      </xsl:if>
      </xsl:template>

      <xsl:template match="formField/@name">
      <xsl:attribute name="name">
      <xsl:value-of select="translate(., '.', '_')"/>
      </xsl:attribute>
      </xsl:template>

      <xsl:template match="body/@width">
      <xsl:variable name="current-body-width" select="."/>
      <xsl:attribute name="width">
      <xsl:for-each select="..//formField/geometryInfo" >
      <xsl:sort select="@x + @width + $x-offset + $sup-display-width" data-type="number" order="descending"/>
      <xsl:if test="position()=1">
      <xsl:variable name="max-width" select="@x + @width + $x-offset + $sup-display-width"/>
      <xsl:choose>
      <xsl:when test="$max-width &gt; $current-body-width">
      <xsl:choose>
      <xsl:when test="$max-width + $clearanceBuffer &gt; $nPageWidth">
      <xsl:value-of select=" $nPageWidth - $clearanceBuffer"/>
      </xsl:when>
      <xsl:otherwise>
      <xsl:value-of select="$max-width + $clearanceBuffer "/>
      </xsl:otherwise>
      </xsl:choose>
      </xsl:when>
      <xsl:otherwise>
      <xsl:choose>
      <xsl:when test="$current-body-width + $clearanceBuffer &gt; $nPageWidth">
      <xsl:value-of select=" $nPageWidth - $clearanceBuffer "/>
      </xsl:when>
      <xsl:otherwise>
      <xsl:value-of select="$current-body-width + $clearanceBuffer "/>
      </xsl:otherwise>
      </xsl:choose>
      </xsl:otherwise>
      </xsl:choose>
      </xsl:if>
      </xsl:for-each>
      </xsl:attribute>
      </xsl:template>

      <xsl:template match="frame/geometryInfo/@width">
      <xsl:variable name="current-frame-width" select="."/>
      <xsl:attribute name="width">
      <xsl:for-each select="../..//formField/geometryInfo" >
      <xsl:sort select="@x + @width + $x-offset + $sup-display-width" data-type="number" order="descending"/>
      <xsl:if test="position()=1">
      <xsl:variable name="max-width" select="@x + @width + $x-offset + $sup-display-width"/>
      <xsl:choose>
      <xsl:when test="$max-width &gt; $current-frame-width">
      <xsl:choose>
      <xsl:when test="$max-width + $clearanceBuffer &gt; $nPageWidth">
      <xsl:value-of select=" $nPageWidth - $clearanceBuffer"/>
      </xsl:when>
      <xsl:otherwise>
      <xsl:value-of select="$max-width + $clearanceBuffer "/>
      </xsl:otherwise>
      </xsl:choose>
      </xsl:when>
      <xsl:otherwise>
      <xsl:choose>
      <xsl:when test="$current-frame-width + $clearanceBuffer &gt; $nPageWidth">
      <xsl:value-of select=" $nPageWidth - $clearanceBuffer "/>
      </xsl:when>
      <xsl:otherwise>
      <xsl:value-of select="$current-frame-width + $clearanceBuffer "/>
      </xsl:otherwise>
      </xsl:choose>
      </xsl:otherwise>
      </xsl:choose>
      </xsl:if>
      </xsl:for-each>
      </xsl:attribute>
      </xsl:template>

      <xsl:template name="Superscript">
      <xsl:if test="not(contains(@name, 'BLOCK'))">
      <xsl:if test="not(contains(@name, 'PAGE_LABEL'))">
      <xsl:element name="formField">
      <xsl:attribute name="name">
      <xsl:value-of select="concat(translate(@name, '.', '_'), '_SUP')"/>
      <xsl:variable name="hyperlink"><xsl:value-of select="@href" /></xsl:variable>
                          <xsl:value-of select="@href" />
      </xsl:attribute>
      <xsl:element name="geometryInfo">
      <xsl:attribute name="x">
      <xsl:variable name="max-x" select="./geometryInfo/@x + ./geometryInfo/@width + $supx-offset + $sup-display-width"/>
      <xsl:choose>
      <xsl:when test="$max-x + $clearanceBuffer &gt; $nPageWidth">
      <xsl:value-of select="./geometryInfo/@x + ./geometryInfo/@width - $supx-offset - $sup-display-width -$clearanceBuffer "/>
      </xsl:when>
      <xsl:otherwise>
      <xsl:value-of select="./geometryInfo/@x + ./geometryInfo/@width + $supx-offset"/>
      </xsl:otherwise>
      </xsl:choose>
      </xsl:attribute>
      <xsl:attribute name="y">
      <xsl:variable name="frame_name" select="../@name" />
      <xsl:variable name="frame_height" select="../geometryInfo/@height" />
      <xsl:variable name="page_num" select="substring($frame_name,10) " />
      <xsl:variable name="current_page_num" select="$page_num - 1 " />
      <xsl:variable name="min-field-y" select=" ./geometryInfo/@y + $y-offset - $sup-display-height"/>
      <xsl:variable name="check_y" select=" $frame_height * $current_page_num "/>
      <xsl:choose>
      <xsl:when test="$min-field-y &lt; $check_y ">
      <xsl:value-of select=" $check_y + $little_push "/>
      </xsl:when>
      <xsl:otherwise>
      <xsl:value-of select="./geometryInfo/@y + $y-offset "/>
      </xsl:otherwise>
      </xsl:choose>
      </xsl:attribute>
      <xsl:attribute name="width">
      <xsl:value-of select="$sup-display-width"/>
      </xsl:attribute>
      <xsl:attribute name="height">
      <xsl:value-of select="$sup-display-height"/>
      </xsl:attribute>
      </xsl:element>
      <!-- start of sup field elements other than geometry -->
      <xsl:element name="textBox">
      <xsl:attribute name="readOnly">
      <xsl:value-of select="'no'" />
      </xsl:attribute>
      <xsl:attribute name="visibility">
      <xsl:value-of select="'visible'" />
      </xsl:attribute>
      <xsl:attribute name="required">
      <xsl:value-of select="'no'" />
      </xsl:attribute>
      <xsl:attribute name="defaultText">
      <xsl:value-of select="''" />
      </xsl:attribute>
      <xsl:attribute name="alignment">
      <xsl:value-of select="'left'" />
      </xsl:attribute>
      <xsl:attribute name="multiLine">
      <xsl:value-of select="'no'" />
      </xsl:attribute>
      <xsl:attribute name="scroll">
      <xsl:value-of select="'yes'" />
      </xsl:attribute>
      <xsl:attribute name="maxCharacters">
      <xsl:value-of select="'200'" />
      </xsl:attribute>
      <xsl:attribute name="checkSpelling">
      <xsl:value-of select="'no'" />
      </xsl:attribute>
      </xsl:element>
      <xsl:element name="font">
      <xsl:attribute name="face">
      <xsl:value-of select="'Arial'" />
      </xsl:attribute>
      <xsl:attribute name="size">
      <xsl:value-of select="'6'" />
      </xsl:attribute>
      <xsl:attribute name="bold">
      <xsl:value-of select="'no'" />
      </xsl:attribute>
      <xsl:attribute name="italic">
      <xsl:value-of select="'no'" />
      </xsl:attribute>
      <xsl:attribute name="underline">
      <xsl:value-of select="'no'" />
      </xsl:attribute>
      <xsl:attribute name="strikeout">
      <xsl:value-of select="'no'" />
      </xsl:attribute>
      <xsl:attribute name="textColor">
      <xsl:value-of select="'blue'" />
      </xsl:attribute>
      </xsl:element>
      <xsl:element name="visualSettings">
      <xsl:attribute name="hideLeftBorder">
      <xsl:value-of select="'yes'" />
      </xsl:attribute>
      <xsl:attribute name="hideRightBorder">
      <xsl:value-of select="'yes'" />
      </xsl:attribute>
      <xsl:attribute name="hideTopBorder">
      <xsl:value-of select="'yes'" />
      </xsl:attribute>
      <xsl:attribute name="hideBottomBorder">
      <xsl:value-of select="'yes'" />
      </xsl:attribute>
      </xsl:element>
      <!-- end of sup field elements other than geometry -->
      </xsl:element>
      </xsl:if>
      </xsl:if>
      </xsl:template>

      <xsl:template match="frame/formField/font">
      <xsl:if test="not(string-length(normalize-space(@face))=0)">
      <xsl:copy>
      <xsl:apply-templates select="@* | node()"/>
      <xsl:apply-templates/>
      </xsl:copy>
      </xsl:if>
      <xsl:if test="string-length(normalize-space(@face))=0">
      <xsl:copy>
      <xsl:apply-templates select="@* | node()"/>
      <xsl:apply-templates/>
      <xsl:attribute name="face">
      <xsl:value-of select="'Arial'"/>
      </xsl:attribute>
      <xsl:attribute name="size">
      <xsl:value-of select="'9'"/>
      </xsl:attribute>
      <xsl:attribute name="bold">
      <xsl:value-of select="'no'" />
      </xsl:attribute>
      <xsl:attribute name="italic">
      <xsl:value-of select="'no'" />
      </xsl:attribute>
      <xsl:attribute name="underline">
      <xsl:value-of select="'no'" />
      </xsl:attribute>
      <xsl:attribute name="strikeout">
      <xsl:value-of select="'no'" />
      </xsl:attribute>
      <xsl:attribute name="textColor">
      <xsl:value-of select="'blue'" />
      </xsl:attribute>
      </xsl:copy>
      </xsl:if>
      </xsl:template>

      <xsl:template match="frame/formField">
      <xsl:choose>
      <xsl:when test="textBox/@visibility='hidden' or checkBox/@visibility='hidden'">
      </xsl:when>
      <xsl:otherwise>
      <xsl:copy>
      <xsl:apply-templates select="@* | node()"/>
      <xsl:if test="not(font)">
      <xsl:element name="font">
      <xsl:attribute name="face">
      <xsl:value-of select="'Arial'" />
      </xsl:attribute>
      <xsl:attribute name="size">
      <xsl:value-of select="./geometryInfo/@width*$c_factor "/>
      </xsl:attribute>
      <xsl:attribute name="bold">
      <xsl:value-of select="'no'" />
      </xsl:attribute>
      <xsl:attribute name="italic">
      <xsl:value-of select="'no'" />
      </xsl:attribute>
      <xsl:attribute name="underline">
      <xsl:value-of select="'no'" />
      </xsl:attribute>
      <xsl:attribute name="strikeout">
      <xsl:value-of select="'no'" />
      </xsl:attribute>
      <xsl:attribute name="textColor">
      <xsl:value-of select="'blue'" />
      </xsl:attribute>
      </xsl:element>
      </xsl:if>
      </xsl:copy>
      </xsl:otherwise>
      </xsl:choose>
      </xsl:template>
      </xsl:stylesheet>