xsl-list
[Top] [All Lists]

regexp question

2004-09-12 07:57:59
Using XSLT 2.o, I want to take this:

        <meta name="pdate" content="20001123"/>

.... and get this:

        <meta name="dateIssued" content="2000-11-23"/>

Why isn't the following pattern matching (in the xhtml:meta template), and is there a better way?

    <xsl:when test="@name='pdate'">
<xsl:analyze-string select="@content" regex='(\d[4])(\d[2])(\d[2])'>
        <xsl:matching-substring>
          <meta name="dateIssued">
            <xsl:attribute name="content">
              <xsl:value-of select="regex-group(1)"/>
              <xsl:text>-</xsl:text>
              <xsl:value-of select="regex-group(2)"/>
              <xsl:text>-</xsl:text>
              <xsl:value-of select="regex-group(3)"/>
            </xsl:attribute>
          </meta>
        </xsl:matching-substring>
        <xsl:non-matching-substring>
          <meta name="dateIssued" content="{.}"/>
        </xsl:non-matching-substring>
      </xsl:analyze-string>
    </xsl:when>

Bruce



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