xsl-list
[Top] [All Lists]

Re: [xsl] formatting not able to retain

2016-05-06 07:12:45
I think this is why your title text is coming out twice:

 <xsl:apply-templates select="named-content[@content-type='list-head']"/>
 <xsl:variable name="text" select="replace(., '  ', ' &#160;')"/>

You're outputting list-head specifically, and then when you grab everything and 
put it into text, that includes the list-head, so when you output text, it's 
got the list-head in it.

Michele

*******
Michele Combs
Lead Archivist, Special Collections Research Center
Syracuse University
315-443-2081
mrrothen(_at_)syr(_dot_)edu

________________________________________
From: Joga Singh Rawat jrawat(_at_)aptaracorp(_dot_)com 
<xsl-list-service(_at_)lists(_dot_)mulberrytech(_dot_)com>
Sent: Friday, May 6, 2016 2:59 AM
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: [xsl] formatting not able to retain

Dear experts,
We are not able to retain formatting elements ie. bold, italic within following 
example. At the same time title text is also gets duplicate. Can anyone give me 
any clue regarding this. Thanks in advance

XSL
<xsl:template match="preformat">
 <literallayout type="programlisting">
  <xsl:apply-templates 
select="named-content[@content-type='list-head']/named-content[@content-type='label']"
 mode="list-label"/>
  <xsl:apply-templates select="named-content[@content-type='list-head']"/>
   <xsl:variable name="text" select="replace(., '  ', ' &#160;')"/>
   <xsl:analyze-string select="$text" regex="[\n\r]">
      <xsl:non-matching-substring>
       <line><xsl:value-of select="."/></line>
    </xsl:non-matching-substring>
   </xsl:analyze-string>
</xsl:template>

Input
<preformat id="list1">
<named-content content-type="list-head">
<named-content content-type="label">Listing 3.1</named-content> Listing 
Head</named-content>
01 <bold>public class</bold> Mitarbeiter {
02   <italic>// Attribute</italic>
03   private final String name;
04   private&ndash;final int personalNummer;
05   private double gehalt;}
</preformat>

Current output
<literallayout type="programlisting" id="list1">
<number>Listing 3.1</number><ti>Listing Head</ti>
<line>Listing 3.1 Listing Head</line>
<line>01 public class Mitarbeiter {</line>
<line>02 Â  // Attribute</line>
<line>03 Â  private final String name;</line>
<line>04   private–final int personalNummer;</line>
<line>05 Â  private double gehalt;}</line>
</literallayout>

Required output
<literallayout type="programlisting" id="list1">
<number>Listing 3.1</number><ti>Listing Head</ti>
<line>01 <b>public class</b> Mitarbeiter {</line>
<line>02 Â  <i>// Attribute</i></line>
<line>03 Â  private-final String name;</line>
<line>04   private–final int personalNummer;</line>
<line>05 Â  private double gehalt;}</line>
</literallayout>


...JSR
--~----------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
EasyUnsubscribe: http://lists.mulberrytech.com/unsub/xsl-list/1167547
or by email: xsl-list-unsub(_at_)lists(_dot_)mulberrytech(_dot_)com
--~--

<Prev in Thread] Current Thread [Next in Thread>