2021-07-11

XSLT 1.0 in-browser Q&A

  • How to get XSLT path from within XSLT?

<xsl:value-of select="substring-before(substring-after(/processing-instruction('xml-stylesheet'),'href=&quot;'),'&quot;')"/>

XML: <?xml-stylesheet type="text/xsl" href="../AsTable.xsl" ?>

Gives: ../AsTable.xsl

  • How to get relative URL of  specific XSLT from XML?

<xsl:value-of select="substring-before(substring-after(/processing-instruction('xml-stylesheet'),'href=&quot;'),'AsTable.xsl&quot;')"/>

    Gives: ../


    • How to get Javascript URL relative to XSLT applied to XML as processing instruction?
    XSLT:
    <xsl:param name="baseUrl" select="substring-before(substring-after(/processing-instruction('xml-stylesheet'),'href=&quot;'),'AsTable.xsl&quot;')"  />
    <script type="module" src="{$baseUrl}XmlView.js">/**/</script> 

    Gives: ../XmlView.js


      • list of unique children tags (each last)
      *[ not( name() = name(following-sibling::*) ) ]
      • how to output XSL from XSL
      Add namespace with altered URL, namespace-alias, use the namespace in output:
      <xsl:stylesheet version="1.0"
      xmlns="http://www.w3.org/1999/xhtml"
      xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
      xmlns:xvxsl="http://www.w3.org/1999/XSL/TransformAlias">
      <!--
      * get entries for table presentation and
      * fills in xsl:template mode="DisplayAs" for each
      -->
      <xsl:output method="xml" />
      <xsl:namespace-alias stylesheet-prefix="xvxsl" result-prefix="xsl"/> ...
      <xvxsl:template mode="DisplayAs" match="{$xPath}">
      • how to debug XSL? 
      Currently the most convenient way is given by Visual Studio Pro edition. Trial available.

      No comments:

      Post a Comment