Skip to content

Instantly share code, notes, and snippets.

@martin-honnen
Last active August 7, 2023 13:30
Show Gist options
  • Select an option

  • Save martin-honnen/00fdd29c6a33584251ecf205987b4b1d to your computer and use it in GitHub Desktop.

Select an option

Save martin-honnen/00fdd29c6a33584251ecf205987b4b1d to your computer and use it in GitHub Desktop.

Revisions

  1. martin-honnen revised this gist Aug 7, 2023. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions xslt-with-document-use1.xsl
    Original file line number Diff line number Diff line change
    @@ -2,6 +2,7 @@
    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    version="3.0"
    xmlns:data="http://example.com/mh/data"
    expand-text="yes"
    exclude-result-prefixes="data">

    <data:data>
  2. martin-honnen created this gist Aug 7, 2023.
    8 changes: 8 additions & 0 deletions sample1.xml
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,8 @@
    <root>
    <item>
    <value>a</value>
    </item>
    <item>
    <value>b</value>
    </item>
    </root>
    18 changes: 18 additions & 0 deletions xslt-with-document-use1.xsl
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,18 @@
    <?xml version="1.0" encoding="utf-8"?>
    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    version="3.0"
    xmlns:data="http://example.com/mh/data"
    exclude-result-prefixes="data">

    <data:data>
    <map key="a">1</map>
    <map key="b">2</map>
    </data:data>

    <xsl:mode on-no-match="shallow-copy"/>

    <xsl:template match="item/value">
    <xsl:copy>{document('')/xsl:stylesheet/data:data/map[@key = current()]}</xsl:copy>
    </xsl:template>

    </xsl:stylesheet>