Project

Profile

Help

Bug #3333

closed

Using an XSLT 3.0 package indirectly by several routes

Added by Mark Dunn over 7 years ago. Updated over 7 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
XSLT 3.0 packages
Sprint/Milestone:
-
Start date:
2017-07-04
Due date:
% Done:

100%

Estimated time:
Legacy ID:
Applies to branch:
9.8
Fix Committed on Branch:
9.8
Fixed in Maintenance Release:
Platforms:

Description

I'd like to be able to create a single package of common functions, variables, etc.

Something like this:

<xsl:package 
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
    xmlns:xd="http://www.oxygenxml.com/ns/doc/xsl" 
    xmlns:xs="http://www.w3.org/2001/XMLSchema" 
    name="http://www.oup.com/oup-academic-common-package"
    package-version="0.1"
    version="3.0">
        
    <xsl:use-package name="http://www.oup.com/logger" package-version="0.1"/>
    <xsl:use-package name="http://www.oup.com/generalVariables" package-version="0.1"/>
    <xsl:use-package name="http://www.oup.com/getDTD" package-version="0.1"/>
        
</xsl:package>

Both "logger" and "getDTD" packages need to use the "generalVariables" package.

The "generalVariables" package also needs to be available to the stylesheet that uses the "oup-academic-common-package".

My first attempt threw up duplicate variable error messages.

Then I had a go with xsl:accept. So now both the "logger" and "getDTD" packages contain this statement:

  <xsl:use-package name="http://www.oup.com/generalVariables" package-version="0.1">
    <xsl:accept component="*" names="*" visibility="private"/>
  </xsl:use-package>

Now my error message is:

java.lang.AssertionError: Saxon can't find the new component corresponding to variable oupdtg:filePathSeparator

oupdtg:fileSeparator is a variable defined in the "generalVariables" package:

<xsl:package 
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:xs="http://www.w3.org/2001/XMLSchema" 
    xmlns:xd="http://www.oxygenxml.com/ns/doc/xsl"
    xmlns:oupdtg="http://www.oup.com/oupdtg" 
    name="http://www.oup.com/generalVariables"
    package-version="0.1"
    exclude-result-prefixes="#all"
    version="3.0">
    
    <xsl:variable name="oupdtg:newLine" as="xs:string" visibility="public">
        <xsl:text>&#x000d;&#x000a;</xsl:text>
    </xsl:variable>
    
    <xsl:variable name="oupdtg:quot" as="xs:string" visibility="public" select="'&quot;'"/>

    <xsl:variable name="oupdtg:filePathSeparator" as="xs:string" visibility="public" select="'[\\/]'"/>
     
</xsl:package>

If I use the three packages directly within my stylesheet (rather than wrapping them in the "oup-academic-common-package", the stylesheet works fine.

But is it possible to create this wrapper package?


Files

test-packages.zip (6.65 KB) test-packages.zip Stylesheets and packages for testing use-package hierarchy and visibility Mark Dunn, 2017-07-05 09:59

Related issues

Has duplicate Saxon - Bug #3367: function not found inside xslt packageDuplicateO'Neil Delpratt2017-07-31

Actions

Please register to edit this issue

Also available in: Atom PDF