[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: formatting not able to retain

Subject: Re: formatting not able to retain
From: "Michael Müller-Hillebrand mmh@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Fri, 6 May 2016 08:29:49 -0000
Re:  formatting not able to retain
Good morning,

> Am 06.05.2016 um 08:59 schrieb Joga Singh Rawat jrawat@xxxxxxxxxxxxxx
<xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>:
>
> 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']"/>

This line processes the child element named-content[@content-type='label'] a
second time.

>   <xsl:variable name="text" select="replace(., '  ', ' &#160;')"/>

Here you put the full string content of <preformat> in a single string. That
is where your inline elements go away.

I guess you would need an apply-templates here and if you need change spaces
in nbsp you better have an individual template for text() with a suitable
mode.

HTH,

- Michael


>   <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 C  // Attribute</line>
> <line>03 C  private final String name;</line>
> <line>04 C  privateC"b,bfinal int personalNummer;</line>
> <line>05 C  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 C  <i>// Attribute</i></line>
> <line>03 C  private-final String name;</line>
> <line>04 C  privateC"b,bfinal int personalNummer;</line>
> <line>05 C  private double gehalt;}</line>
> </literallayout>

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.