how to replace < nbsp > and < i > tags to spaces

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • kannadhasan
    New Member
    • Mar 2008
    • 2

    how to replace < nbsp > and < i > tags to spaces

    Hi,
    am a new bee using xsl to convert xml page to another xml fomat. While I process a para which looks like:

    <p>
    <b>Sample text:</b>
    <nbsp/>these are some sample text<i>text continues here</i>
    </p>

    I want the string inside the para and when I read, I get the output string of the para as:
    Sample text:these are some sample texttext continues here

    In those places where I have italics tag and nbsp tag there are no spaces. Please help me to find a solution to replace the <nbsp> and <i> tags to spaces

    (I have made it bold to specify where I need spaces)
    Last edited by kannadhasan; Mar 12 '08, 06:05 AM. Reason: added email notification
  • pronerd
    Recognized Expert Contributor
    • Nov 2006
    • 392

    #2
    Review the w3cschools site. They have a lot of basic examples of using XSL.

    You want something like.

    Code:
        <xsl:for-each select="//nbsp">
            <xsl:value-of > </xsl:value-of >
        </xsl:for-each>

    Comment

    • jkmyoung
      Recognized Expert Top Contributor
      • Mar 2006
      • 2057

      #3
      I suggest creating a default template like so:

      [code=xml]
      <xsl:template match="*">
      <xsl:apply-templates/>
      <xsl:text> </xsl:text>
      </xsl:template>
      [/code]

      This adds a space after every close element.

      To be honest, it's the source xml that is the real problem, but I guess you work with what you get.

      Comment

      Working...