-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Sample code for "Overriding Global XSLT Variables in XSpec, Part 3" (#59
) * Rename XSpec file for better alignment with Part 3 * Sample code for "Overriding Global XSLT Variables in XSpec, Part 3"
- Loading branch information
Showing
8 changed files
with
108 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# Sample code for "Overriding Global XSLT Variables in XSpec, Part 3" | ||
|
||
Example files combining `run-as="external"` with `xsl:package/xsl:variable`: | ||
|
||
- `production-pkg/production-pkg.xsl` | ||
- `test-only-pkg/test-only-pkg.xsl` | ||
- `config.xml` | ||
- `external_override-in-test-only-pkg.xspec` | ||
|
||
#### Links to Topic | ||
[Overriding Global XSLT Variables in XSpec, Part 3](https://medium.com/@xspectacles/overriding-global-xslt-variables-in-xspec-part-3-545205cef963) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
Sample Code for "Overriding Global XSLT Variables in XSpec, Part 3" | ||
https://medium.com/@xspectacles/overriding-global-xslt-variables-in-xspec-part-3-545205cef963 | ||
--> | ||
<configuration xmlns="http://saxon.sf.net/ns/configuration"> | ||
<xsltPackages> | ||
<package name="urn:x-xspectacles:pkgs:production-pkg" | ||
version="1.0" | ||
sourceLocation="production-pkg/production-pkg.xsl"/> | ||
<package name="urn:x-xspectacles:pkgs:test-only-pkg" | ||
version="1.0" | ||
sourceLocation="test-only-pkg/test-only-pkg.xsl"/> | ||
</xsltPackages> | ||
</configuration> | ||
<!-- Copyright © 2024 by Amanda Galtman. --> |
32 changes: 32 additions & 0 deletions
32
src/override-global-var-part3/external_override-in-test-only-pkg.xspec
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
<x:description run-as="external" | ||
stylesheet="test-only-pkg/test-only-pkg.xsl" | ||
xslt-version="3.0" | ||
xmlns:x="http://www.jenitennison.com/xslt/xspec"> | ||
|
||
<!-- | ||
Sample Code for "Overriding Global XSLT Variables in XSpec, Part 3" | ||
https://medium.com/@xspectacles/overriding-global-xslt-variables-in-xspec-part-3-545205cef963 | ||
--> | ||
|
||
<x:variable name="x:saxon-config" href="config.xml"/> | ||
<x:scenario> | ||
<x:label> | ||
Test-only package overrides global xsl:variable as xsl:param | ||
during external transformation to test an XSLT package | ||
</x:label> | ||
<x:scenario label="With x:param, template uses"> | ||
<x:param name="my-param" select="'from x:param'"/> | ||
<x:param name="data-file-name" select="'test-data1.xml'"/> | ||
<x:call template="show-values-of-globals"/> | ||
<x:expect label="the provided values" | ||
select="('from x:param', 'test-data1.xml')"/> | ||
</x:scenario> | ||
<x:scenario label="Without x:param, template uses"> | ||
<x:call template="show-values-of-globals"/> | ||
<x:expect label="values from production and xsl:override" | ||
select="('from production', 'test-data-from-override.xml')"/> | ||
</x:scenario> | ||
</x:scenario> | ||
</x:description> | ||
<!-- Copyright © 2024 by Amanda Galtman. --> |
22 changes: 22 additions & 0 deletions
22
src/override-global-var-part3/production-pkg/production-pkg.xsl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<xsl:package name="urn:x-xspectacles:pkgs:production-pkg" | ||
package-version="1.0" version="3.0" | ||
xmlns:xs="http://www.w3.org/2001/XMLSchema" | ||
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> | ||
|
||
<!-- | ||
Sample Code for "Overriding Global XSLT Variables in XSpec, Part 3" | ||
https://medium.com/@xspectacles/overriding-global-xslt-variables-in-xspec-part-3-545205cef963 | ||
--> | ||
|
||
<xsl:param name="my-param" as="xs:string" | ||
select="'from production'"/> | ||
<xsl:variable name="data-file-name" as="xs:string" | ||
select="'production.xml'" visibility="public"/> | ||
|
||
<xsl:template name="show-values-of-globals" visibility="public"> | ||
<xsl:sequence select="($my-param, $data-file-name)"/> | ||
</xsl:template> | ||
|
||
</xsl:package> | ||
<!-- Copyright © 2024 by Amanda Galtman. --> |
24 changes: 24 additions & 0 deletions
24
src/override-global-var-part3/test-only-pkg/test-only-pkg.xsl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<xsl:package name="urn:x-xspectacles:pkgs:test-only-pkg" | ||
package-version="1.0" version="3.0" | ||
xmlns:xs="http://www.w3.org/2001/XMLSchema" | ||
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> | ||
|
||
<!-- | ||
Sample Code for "Overriding Global XSLT Variables in XSpec, Part 3" | ||
https://medium.com/@xspectacles/overriding-global-xslt-variables-in-xspec-part-3-545205cef963 | ||
--> | ||
|
||
<xsl:use-package name="urn:x-xspectacles:pkgs:production-pkg" | ||
version="1.0"> | ||
<xsl:accept component="template" names="show-values-of-globals" | ||
visibility="public"/> | ||
<xsl:override> | ||
<!-- Override xsl:variable with xsl:param --> | ||
<xsl:param name="data-file-name" as="xs:string" | ||
select="'test-data-from-override.xml'"/> | ||
</xsl:override> | ||
</xsl:use-package> | ||
|
||
</xsl:package> | ||
<!-- Copyright © 2024 by Amanda Galtman. --> |