I have an xslt document and I want to output an anchor (a) tag with some attributes whose value is the other things. it depends on. Thus, I use the ESL: attribute tag below / if below (or sub-reverse). So my code looks like this:
& lt; A href = "/ somepage.html" & gt; & Lt; Xsl: if test = "current_page = 'this_page'" & gt; & Lt; Xsl: attribute name = 'square' & gt; Active & lt; / Xsl: attribute & gt; & Lt; / XSL: If & gt; My page & lt; / A & gt; However, the problem occurs, in HTML output, there are all new lines / spaces, which is an extra space on the left side (and it has been underlined) to end my link.
, making it clear). So the obvious solution is to: & lt; A href = "/ somepage.html" & gt; & Lt; Xsl: if test = "current_page = 'this_page'" & gt; & Lt; Xsl: attribute name = 'class' & gt; Active & lt; / Xsl: attribute & gt; & Lt; / Xsl: if & gt; My page & lt; / A & gt;
To get rid of space is not a big deal in the above code, but my actual page has a lot of logic for it, so it's really ugly. The only other thing I can think of cleaning it is that the link can put logic out of the generation, but then I repeat things and am trying to make more variables. Which is fair but not yet perfectly ideal. This is just an example where I wanted to do this, it happened many times, so I was wondering if there are other ways to solve it.
Post text "itemprop =" text ">
Perhaps you can use it at the beginning of the XSLT document:
Update, This works:
& lt; a href = "/ Somepage.html" & gt; xsl: if test = "current_page = 'this_page'" & gt; & lt; xsl: attribute name = 'class' & gt; active & lt; / xsl: attribute & Gt; & lt; / XSL: If & gt; & lt; xsl: text & gt; my page & lt; / xsl: text & gt; & lt; / a & gt;
< / Div>
Comments
Post a Comment