Announcement

Collapse
No announcement yet.

Text in Worte zerlegen

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Text in Worte zerlegen

    Hallo

    Vielleich hat jemand von euch eine Idee oder Hinweis.

    Ich muss den Text in Worte zerlegen.
    Mein Lösungsansatz gibt allerdings nur ein Wort aus:

    Code:
    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
    <xsl:template match="/">
          <xsl:call-template name="tokenToElement">
            <xsl:with-param name="words" select="'hallo ich bin ein Text'"/>
          </xsl:call-template>
    </xsl:template>
    
    
    <xsl:template match="keywords" name="tokenToElement">
      <xsl:param name="words" select="concat(.,' ')"/>
      <xsl:choose>
        <xsl:when test="string-length($words)>1">
          <keyword>
             <xsl:value-of select="substring-before($words,' ')"/>
          </keyword>
          <xsl:call-template name="tokenToElement">
            <xsl:with-param name="words" select="substring-before($words,' ')"/>
          </xsl:call-template>
        </xsl:when>
      </xsl:choose>
    </xsl:template>
    
    </xsl:stylesheet>

    Danke im Voraus

  • #2
    Probiere diesen Ansatz:
    [highlight=xml]<xsl:template match="keywords" name="tokenToElement">
    <xslaram name="words"/>
    <xsl:if test="string-length($words)>0">
    <keyword>
    <xsl:value-of select="substring-before(concat($words,' '),' ')"/>
    </keyword>
    <xsl:call-template name="tokenToElement">
    <xsl:with-param name="words" select="substring-after($words,' ')"/>
    </xsl:call-template>
    </xsl:if>
    </xsl:template>[/highlight]

    Comment


    • #3
      Super klappt perfekt. Vielen Dank

      Comment

      Working...
      X