tag:help-archives.hannonhill.com,2010-02-09:/discussions/how-do-i/206-system-tags-inside-attributesCascade CMS: Discussion 2011-06-02T20:47:36Ztag:help-archives.hannonhill.com,2010-02-09:Comment/33820882010-10-17T21:23:05Z2010-10-17T21:24:25ZSystem tags inside attributes<div><p>Joseph,<br />
The key problem is that the two lines…</p>
<pre><code> <xsl:attribute name="class">blah</xsl:attribute>
<xsl:copy-of select="@*"/></code></pre>
<p>…were cancelling each other out.</p>
<p>You created an attribute with <code>name()</code> 'class', and then copied all the attributes from the original element. That caused the original class attribute to overwrite the new one. The fix for this is to have it copy all the old attributes <strong>except</strong> the old class attribute: <code><xsl:copy-of select="@*[name() != 'class']"/></code>.</p>
<p>There are a few other finer points here, though, that could cause you heartache down the road if you apply this globally to your templates:</p>
<ul>
<li>The first <code><xsl:copy-of select="@*" /></code> statement will cause an error because it copies the attributes <em>after</em> all the other child nodes. XSLT requires that attribute nodes be copied first.</li>
<li>Second, your stylesheet does not match <code>comment()</code> nodes, so it will strip all comments that may be embedded in your Template and Block assets or generated using <code><xsl:comment></code> in your other Formats.</li>
</ul>
<p>Here's a modified version of your stylesheet that addresses these issues (also attached for download, if you want):</p>
<pre><code><?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<!-- BEGIN XSLT pass-through copy templates -->
<xsl:template match="/">
<xsl:apply-templates />
</xsl:template>
<xsl:template match="@*|*" priority="-1">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="comment()">
<xsl:copy-of select="."/>
</xsl:template>
<xsl:template match="text()">
<xsl:value-of select="."/>
</xsl:template>
<!-- END XSLT pass-through copy templates -->
<xsl:template match="*[@class='replace_me']">
<xsl:copy>
<xsl:attribute name="class">blah</xsl:attribute>
<xsl:copy-of select="@*[name() != 'class']"/>
<xsl:copy-of select="./node()"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet></code></pre></div>Rosstag:help-archives.hannonhill.com,2010-02-09:Comment/33820882010-10-18T18:43:52Z2010-10-18T18:43:53ZSystem tags inside attributes<div><p>Thanks again Ross! This got us really close to what we need but now I'm noticing a bit of an issue. After applying this XSLT to a page one of our navigation menus, which is rendered in PHP placed inside an XSLT applied to an index block, is being completely erased in the published page.<br />
</p>
<p>When I comment out the replace_me template below the pass-through copy template the results are the same. The navigation PHP spits out markup in the form of <code><ul><li class="class_name"><a href="/heref/here">Name</a></li>[more li tags]</ul></code>. There is a <ul> tag within the navigation XSLT that is coming out in the published page but everything within it is blank.<br />
</p>
<p>When I unlink the rewrite replace me XSLT from the page and publish, the navigation comes out as expected.<br />
</p>
<p>As always, thanks a bunch!</p></div>Josephtag:help-archives.hannonhill.com,2010-02-09:Comment/33820882010-10-21T16:28:00Z2010-10-21T16:28:00ZSystem tags inside attributes<div><p>Sorry for the bump, we're really hoping to implement this soon.</p></div>Josephtag:help-archives.hannonhill.com,2010-02-09:Comment/33820882010-10-25T14:40:57Z2010-10-25T14:40:57ZSystem tags inside attributes<div><p>Hm,</p>
<p>Can you send me your actual source XML? An example of the page without the<br />
transformation would be fine; you don't need to create anything special.</p>
<p>Cheers,</p>
<p>Ross</p>
<p>On Thu, Oct 21, 2010 at 12:30 PM, Joseph <<br />
<a href="mailto:tender+db73c68837dbfc7287912f9e5a72ac962fb030005@tenderapp.com">tender+db73c68837dbfc7287912f9e5a72ac962fb030005@tenderapp.com</a><<a href="mailto:tender%2Bdb73c68837dbfc7287912f9e5a72ac962fb030005@tenderapp.com">tender%2Bdb73c68837dbfc7287912f9e5a72ac962fb030005@tenderapp.com</a>><br />
</p>
<blockquote><p>wrote:</p></blockquote></div>Rosstag:help-archives.hannonhill.com,2010-02-09:Comment/33820882010-10-25T20:38:44Z2010-10-25T20:38:44ZSystem tags inside attributes<div><p>Hi Ross,</p>
<p>Thanks again for the reply, I have all the example files but the before and after published page have quite a bit of markup and other text referring directly to our client so I'm not sure if posting it on a public forum is the way to go. Is there a more private way for me to get this to you? I want to make sure you have all the information necessary to get us where we'd like to go.<br />
</p>
<p>Thanks Ross,</p>
<p>-Joe</p></div>Josephtag:help-archives.hannonhill.com,2010-02-09:Comment/33820882011-03-02T21:11:05Z2011-03-02T21:11:05ZSystem tags inside attributes<div><p>My goodness, Joe! I'm sorry that i let this ball drop and just
found this while I was going through old forum posts. Do you still
need help with this issue?</p>
<p>Ross</p></div>Ross