...

View Full Version : Placing a result in two locations



TNO
08-13-2008, 07:01 PM
In my XML file I have a custom tag:


<TNO:FOO />

My XSL transforms it into something like this:



<xsl:template match="TNO:FOO">
<script type="text/javascript">
var badPractice = true;
</script>
<div id="title">
<xsl:value-of select="./@text"/>
</div>
</xsl:template>


The problem with this is obvious..I'll have <script> blocks all over the body where they shouldn't be. How would I go about getting that script tag into the head or manipulating a script tag that already exists there? Is it possible to manipulate a transformation during the transformation?

oesxyl
08-13-2008, 11:42 PM
In my XML file I have a custom tag:


<TNO:FOO />

My XSL transforms it into something like this:



<xsl:template match="TNO:FOO">
<script type="text/javascript">
var badPractice = true;
</script>
<div id="title">
<xsl:value-of select="./@text"/>
</div>
</xsl:template>


The problem with this is obvious..I'll have <script> blocks all over the body where they shouldn't be. How would I go about getting that script tag into the head or manipulating a script tag that already exists there? Is it possible to manipulate a transformation during the transformation?
this is the result of a bad designed stylesheet. what you ask is possible but will add a new useless complication. My suggestion is to redesign the stylesheet if you can. Just move the script blocks and add conditionals in the proper template.

regards

TNO
08-14-2008, 12:14 AM
After some more thought I've settled on parsing into an xsl variable as an intermediate step, then applying a template to that variable. Thanks for the advice



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum