Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. XML / XSL
  4. delimiter or tokenizer in xslt

delimiter or tokenizer in xslt

Scheduled Pinned Locked Moved XML / XSL
xmlregextutorialquestionannouncement
2 Posts 2 Posters 6 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    DanielSatheesh
    wrote on last edited by
    #1

    XML

    <?xml version="1.0" encoding="UTF-8"?>
    <!-- Edited by XMLSpy -->
    <catalog>
    <example>
    :20:FT13261793408907
    N23B:CRED
    SA32A:130918USD111670,00
    </example>
    </catalog>
    XSLT

    <?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:output method="text"/>
    <xsl:template match="/">

     <xsl:for-each select="catalog">
     <tr>
          <td><xsl:value-of select="example"> </td>
      </tr>
       </xsl:for-each>
     </xsl:template>
    </xsl:stylesheet>
    

    Current OUTPUT

    :20:FT13261793408907 N23B:CRED SA32A:130918USD111670,00

    Desired OUTPUT

    :20:FT13261793408907
    N23B:CRED
    SA32A:130918USD111670,00
    output must not be in a same line its must be as shown in the desired o/p

    G 1 Reply Last reply
    0
    • D DanielSatheesh

      XML

      <?xml version="1.0" encoding="UTF-8"?>
      <!-- Edited by XMLSpy -->
      <catalog>
      <example>
      :20:FT13261793408907
      N23B:CRED
      SA32A:130918USD111670,00
      </example>
      </catalog>
      XSLT

      <?xml version="1.0" encoding="UTF-8"?>
      <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
      <xsl:output method="text"/>
      <xsl:template match="/">

       <xsl:for-each select="catalog">
       <tr>
            <td><xsl:value-of select="example"> </td>
        </tr>
         </xsl:for-each>
       </xsl:template>
      </xsl:stylesheet>
      

      Current OUTPUT

      :20:FT13261793408907 N23B:CRED SA32A:130918USD111670,00

      Desired OUTPUT

      :20:FT13261793408907
      N23B:CRED
      SA32A:130918USD111670,00
      output must not be in a same line its must be as shown in the desired o/p

      G Offline
      G Offline
      George Jonsson
      wrote on last edited by
      #2

      You don't mention if there can be one or more example nodes within each catalog node. This code works if there are many catalog's with one example node.

      <?xml version="1.0" encoding="utf-8"?>
      <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
      xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl"

      <xsl:output method="text" indent="no"/>

      <xsl:template match="catalog">
      <xsl:value-of select="example"/>
      </xsl:template>

      </xsl:stylesheet>

      And this code works if there are many catalog nodes and many example nodes.

      <?xml version="1.0" encoding="utf-8"?>
      <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
      xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl"

      <xsl:output method="text" indent="no"/>

      <xsl:template match="catalog">
      <xsl:apply-templates select="example" />
      </xsl:template>

      <xsl:template match="example">
      <xsl:value-of select="node()"/>
      </xsl:template>

      </xsl:stylesheet>

      XSLT is recursive by nature, so no need for the loop. If you want text output, I don't understand the HTML tags in your example code.

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups