Setinger
Setinger

Reputation: 169

same path occuring many times in xslt

I am defining few variables and I have select="-------" in them. In those the first parts of the path are the same. Is there any way I can have some sort of a constant type of a thing defined so that I can use it without having to retype the same thing over and over again?

Upvotes: 1

Views: 79

Answers (1)

Martin Honnen
Martin Honnen

Reputation: 167516

Well you can use a variable

<xsl:variable name="foo" select="/a/b/foo"/>
<xsl:variable name="bar" select="$foo/bar"/>
<xsl:variable name="foobar" select="$foo/foobar"/>

instead of

<xsl:variable name="bar" select="/a/b/foo/bar"/>
<xsl:variable name="foobar" select="/a/b/foo/foobar"/>

But as you are already using variables that looks too obvious so maybe I am missing what the problem is.

Upvotes: 3

Related Questions