1

I am trying to insert a jquery datatables into an XSLT sheet after a table and am having a problem with getting it to replace @id with the id of the table like it is in other portions of the script. I suppose it has something to do with escaping, but I tried putting double curly brackets inside the script to no avail. Could someone point me in the right direction?

The portion of my XSLT looks like:

</table>
<script type='text/javascript' src='/js/jquery.dataTables.js'></script>
<script type="text/javascript">
<xsl:text disable-output-escaping="yes" >
    <![CDATA[
    $(document).ready(function() {
        $('{@id}').dataTable({
        "aaSorting": [],
        "sDom": '<"vctable"<"#title"lf>rt<"#bottom"ip><"clear">>',
        "iDisplayLength": 25
        });
        $('{@id}').show();

    });
    ]]>
</xsl:text>
</script>
0

1 Answer 1

1

Use:

<script type="text/javascript">
  <xsl:text disable-output-escaping="yes"><![CDATA[$(document).ready(function() {
    $('#]]></xsl:text>
  <xsl:value-of select="@id"/>
  <xsl:text disable-output-escaping="yes"><![CDATA[').dataTable({
    "aaSorting": [],
    "sDom": '<"vctable"<"#title"lf>rt<"#bottom"ip><"clear">>',
    "iDisplayLength": 25
    });
    $('#]]></xsl:text>
  <xsl:value-of select="@id"/>
  <xsl:text disable-output-escaping="yes"><![CDATA[').show();

});]]></xsl:text>
</script>
Sign up to request clarification or add additional context in comments.

3 Comments

Thank you for pointing me in the right direction. That seems quite repetitive but at least it is working. I edited your post to change the $ to an @ for the attribute and add the # for the id.
I will accept it shortly. I was looking for alternative methods as well. Is there any way to avoid using multiple xsl:text entries?
@Devon, nope. It is the only way as far as I know.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.