Hi there,
Is it possible to check if a certain tag is in use in an XSLT template? With loops you can use the availableloops approach, but is there tag equivalent?
BR.
Lars
Developer forum
E-mail notifications
TagExists in XSLT template
Posted on 18/08/2010 15:57:37
Replies
Posted on 18/08/2010 17:49:48
Hi,
There is no tag, but you can use some xslt functions, for example
<xsl:if test=" MyTag != '' ">
// do something
</xsl:if>
<xsl:if test="string-length(MyTag) > 0">
// do something
</xsl:if>
Best Regard,
Nuno
There is no tag, but you can use some xslt functions, for example
<xsl:if test=" MyTag != '' ">
// do something
</xsl:if>
<xsl:if test="string-length(MyTag) > 0">
// do something
</xsl:if>
Best Regard,
Nuno
Posted on 19/08/2010 08:52:30
Hi Nuno,
I need it the other way around. I want my C# code to check whether a certain tag is used in the XSLT template.
But thanks anyway;-)
BR.
Lars
I need it the other way around. I want my C# code to check whether a certain tag is used in the XSLT template.
But thanks anyway;-)
BR.
Lars
Nicolai Høeg Pedersen
Posted on 19/08/2010 09:06:10
From code use tagexist or loopexist.
Loopexist with xslt requires the "available loops" approach in some situations, but with normal "template tags" like <xsl:value-of select="@MenuText" disable-output-escaping="yes"/>, just use tagexist.
Loopexist with xslt requires the "available loops" approach in some situations, but with normal "template tags" like <xsl:value-of select="@MenuText" disable-output-escaping="yes"/>, just use tagexist.
Posted on 19/08/2010 11:59:23
I tried that to begin with, but in an XSLT template it returns true every time. At least that's what I've experienced. Just to make sure, I tried the following:
Base.wa(Template.TagExists("Yadayada"));
The result was an alert box with the text True:
<script>alert('True');</script><br />
BR.
Lars
Posted on 19/08/2010 14:23:07
Btw. LoopExists works perfectly for this, but TagExists would be much prettier, since it's just a tag and not a loop:)
/Lars
/Lars
Nicolai Høeg Pedersen
Posted on 19/08/2010 14:50:18
Well
Just checked out the code, and there is an issue. I've bugged it, so a fix is coming up.
Untill then do something like this:
If (t.IsXsltTemplate AndAlso t.Html.Contains("@MenuText")) OrElse t.TagExists("MenuText") Then
t.SetTag("MenuText", LongRunningThing())
End If
Just checked out the code, and there is an issue. I've bugged it, so a fix is coming up.
Untill then do something like this:
If (t.IsXsltTemplate AndAlso t.Html.Contains("@MenuText")) OrElse t.TagExists("MenuText") Then
t.SetTag("MenuText", LongRunningThing())
End If
You must be logged in to post in the forum