?
Solved

Adding text pt; at the end of line-height

Posted on 2008-09-30
1
Medium Priority
?
412 Views
Last Modified: 2013-11-18
Hello Experts,

The input xml file contains below structure like...

<p outputclass="line-height: 1.5;text-align: right;"><ph outputclass="color: green;font-size: 9pt;"></ph><xref href="test.html#survey">test</xref><ph outputclass="font-size: 9pt;"><b></b></ph></p>
      <p>

xslt code for this....
<xsl:template match="p[not(parent::entry)][@outputclass]">
    <xsl:variable name="value" select="@outputclass"/>
    <xsl:variable name="margin" select="substring-before(substring-after($value,'margin-left:'),'in;')"/>
    <p>
      <xsl:copy-of select="@*[not(name() = 'class')][not(name() = 'outputclass')]"/>
      <xsl:attribute name="style">
        <xsl:choose>
          <xsl:when test="contains($value,'margin-left:')">
            <xsl:value-of select="number($margin)*96"/>
          </xsl:when>
          <xsl:otherwise>
            <xsl:value-of select="$value"/>  
          </xsl:otherwise>
        </xsl:choose>
      </xsl:attribute>
      <xsl:apply-templates/>
    </p>
  </xsl:template>

In the output which is like below...
<p style="line-height: 1.5;text-align: right;"> for this line i have to add line-height:1.5pt;
         <span style="color: green;font-size: 9pt;"></span>
         <a href="test.html#survey">Test</a>
         <span style="font-size: 9pt;">
            <b></b>
         </span>
      </p>

Can you please suggest what's needs to be updated in xslt code.
0
Comment
Question by:ShaileshShinde
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 60

Accepted Solution

by:
Geert Bormans earned 500 total points
ID: 22612530
Here is what you need to do this.
I am not convinced of the usefullness though
Note that 1.5 lineheight means that it is 1.5 times the font-size, often around 12pt, so line-height would be 18pt
a line-height of 1.5pt is very small
But anyway, I did what you asked for
    <xsl:template match="p[not(parent::entry)][@outputclass]">
        <xsl:variable name="value" select="@outputclass"/>
        <xsl:variable name="changed-value">
            <xsl:analyze-string select="$value" regex="^(.*)(line\-height:\s*[\d\.]+)(pt)?(.*)$">
                <xsl:matching-substring>
                    <xsl:value-of select="regex-group(1)"></xsl:value-of>
                    <xsl:value-of select="regex-group(2)"></xsl:value-of>
                    <xsl:text>pt</xsl:text>
                    <xsl:value-of select="regex-group(4)"></xsl:value-of>
                </xsl:matching-substring>
                <xsl:non-matching-substring>
                    <xsl:value-of select="."></xsl:value-of>
                </xsl:non-matching-substring>
            </xsl:analyze-string>
        </xsl:variable>
        <xsl:variable name="margin" select="substring-before(substring-after($changed-value,'margin-left:'),'in;')"/>
        <p>
            <xsl:copy-of select="@*[not(name() = 'class')][not(name() = 'outputclass')]"/>
            <xsl:attribute name="style">
                <xsl:choose>
                    <xsl:when test="contains($changed-value,'margin-left:')">
                        <xsl:value-of select="number($margin)*96"/>
                    </xsl:when>
                    <xsl:otherwise>
                        <xsl:value-of select="$changed-value"/>  
                    </xsl:otherwise>
                </xsl:choose>
            </xsl:attribute>
            <xsl:apply-templates/>
        </p>
    </xsl:template>

Open in new window

0

Featured Post

Video: Liquid Web Managed WordPress Comparisons

If you run run a WordPress, you understand the potential headaches you may face when updating your plugins and themes. Do you choose to update on the fly and risk taking down your site; or do you set up a staging, keep it in sync with your live site and use that to test updates?

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Matthew
I am a very big proponent of technology compliance standards and strive to meet such criteria in all of my work. That includes my site, which is 100% XHTML 1.0 compliant as determined by the World Wide Web Consortium. https://www.matthewstevenkel…
JavaScript has plenty of pieces of code people often just copy/paste from somewhere but never quite fully understand. Self-Executing functions are just one good example that I'll try to demystify here.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).
Suggested Courses

801 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question