I have this XML:
<EditRemote>
<RemoteVendorServer>
<FriendlyName><![CDATA[blabla]]></FriendlyName>
<Description></Description>
<CommunicationMethod>
<GetExecutors>
<Executor queryString=".*"/>
<Executor queryString="[CX].*"/>
<Executor queryString="[^CX].*"/>
</GetExecutors>
<RemoteAccess/>
</CommunicationMethod>
</RemoteVendorServer>
</EditRemote>
I would like to do applay-templates on “Executor” tags and to collect all queryStrings value into dynamically created hidden inputs with dynamical ID’s. So my code shown below:
<script type="text/javascript">
.
.
var queryCounter = 0;
var c_UNDERSCORE_QUERY_STRING = "_queryString";
.
</script>
.
.
<xsl:apply-templates select="EditRemote/RemoteVendorServer/CommunicationMethod/GetExecutors/Executor" mode="tcp"/>
.
.
// at the bottom of the xsl file I create the template:
<xsl:template match="Executor" mode="tcp">
<input value="{@queryString}">
<xsl:attribute name="id">
<script type="text/javascript">
queryCounter + c_UNDERSCORE_QUERY_STRING+"tcp";
</script>
</xsl:attribute>
<xsl:attribute name="name">
<script type="text/javascript">
queryCounter + c_UNDERSCORE_QUERY_STRING+"tcp";
</script>
</xsl:attribute>
</input>
<script type="text/javascript">
queryCounter++;
</script>
</xsl:template>
What I got back to server is only the last query without the key name. It is somehow got into a different input called Description(textarea element) which is written in the xsl before the apply-templates above:
Server input: …,Description=[^CX].*,…
I even see it in my UI that the query is inside the Description textarea when the page is loaded. What seems to be the problem in my code?
You cannot put script tags into
<xsl:attribute>.And you definitely cannot execute or access JavaScript from within XSLT – why do you think that this would be possible?
Try something like this.
Read about
position()function