MohamedSayed
MohamedSayed

Reputation: 147

Matching variable string in XML tag by XSLT regex

I am new to XSLT world and I want to know how can I match string like <mml:mtable class="ccvccvcvc"> actually I want to match the variable text ccvccvcvc every time and copy it to use in the conversion. The final result should be like:

  1. Input string: <mml:mtable class="xxx">
  2. Output string:<xsl:text>\begin{array}{xxx}</xsl:text><xsl:apply-templates/><xsl:text>\end{array}</xsl:text>

Upvotes: 1

Views: 481

Answers (3)

Michael Kay
Michael Kay

Reputation: 163585

Your input "string" isn't a string, it's an XML element node. And your "output string" isn't a string, it's a fragment of XSLT program text. So I think your reference to regular expressions in the title suggests you are are confused about the XSLT processing model. Remember that XSLT is processing a tree of nodes as input to produce a tree of nodes as output.

I think Martin has probably guessed correctly what you need to do, but I suspect there may be a few gaps in your understanding of XSLT that you need to fix before you can get this working.

Upvotes: 0

Martin Honnen
Martin Honnen

Reputation: 167716

Try

<xsl:template match="mml:mtable[@class]">
  <xsl:text>\begin{array}{</xsl:text>
  <xsl:value-of select="@class"/>
  <xsl:text>}</xsl:text>
  <xsl:apply-templates/>
  <xsl:text>\end{array}</xsl:text>
</xsl:template>

Upvotes: 1

ThW
ThW

Reputation: 19512

It is an attribute so you can use in the mml:table context.

Upvotes: 0

Related Questions