Disabling schema awareness in an enterprise processor when xsl:import-schema is present in the xslt

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Disabling schema awareness in an enterprise processor when xsl:import-schema is present in the xslt

andrew1.welch
Hi,

Is it possible to have an enterprise processor:

new Processor(true)

and run a transform where system-property('xsl:is-schema-aware') returns false, even when the xslt contains <xsl:import-schema> ?

I ask because I want to run some 3rd party xslt 2.0s which use result validation during their testing, but not in prod, in the same processor that runs some xslt 3.0 code...   It seems that xsl:import-schema overrides any configuration I set?

Using Saxon EE 9.6.0.9.

Andrew1 WELCH
XML Developer | Finance & Regulatory IT | HSBC BANK PLC HBEU
8 Canada Square,Canary Wharf,London,E14 5HQ,United Kingdom
__________________________________________________________

Phone 0207 991 9571
Mobile 07717 684 177
Email andrew1.welch@...


__________________________________________________________
Protect our environment - please only print this if you have to!



************************************************************
HSBC Bank plc may be solicited in the course of its placement efforts for a new issue, by investment clients of the firm for whom the Bank as a firm already provides other services. It may equally decide to allocate to its own proprietary book or with an associate of HSBC Group. This represents a potential conflict of interest. HSBC Bank plc has internal arrangements designed to ensure that the firm would give unbiased and full advice to the corporate finance client about the valuation and pricing of the offering as well as internal systems, controls and procedures to identify and manage conflicts of interest.

HSBC Bank plc
Registered Office: 8 Canada Square, London E14 5HQ, United Kingdom
Registered in England - Number 14259
Authorised by the Prudential Regulation Authority and regulated by the Financial Conduct Authority and the Prudential Regulation Authority
************************************************************


-----------------------------------------
SAVE PAPER - THINK BEFORE YOU PRINT!

This E-mail is confidential. 

It may also be legally privileged. If you are not the addressee you may not copy,
forward, disclose or use any part of it. If you have received this message in error,
please delete it and all copies from your system and notify the sender immediately by
return E-mail.

Internet communications cannot be guaranteed to be timely secure, error or virus-free.
The sender does not accept liability for any errors or omissions.


------------------------------------------------------------------------------

_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help 
Reply | Threaded
Open this post in threaded view
|

Re: Disabling schema awareness in an enterprise processor when xsl:import-schema is present in the xslt

Michael Kay
I fear that the answer is no.

The Javadoc for XsltCompiler.setSchemaAware() seems to describe the behaviour correctly

/**
* Say that the stylesheet must be compiled to be schema-aware, even if it contains no
* xsl:import-schema declarations. Normally a stylesheet is treated as schema-aware
* only if it contains one or more xsl:import-schema declarations. If it is not schema-aware,
* then all input documents must be untyped, and validation of temporary trees is disallowed
* (though validation of the final result tree is permitted). Setting the argument to true
* means that schema-aware code will be compiled regardless.
*
* @param schemaAware If true, the stylesheet will be compiled with schema-awareness
* enabled even if it contains no xsl:import-schema declarations. If false, the stylesheet
* is treated as schema-aware only if it contains one or more xsl:import-schema declarations.

But even if you could do this, system-property('xsl:is-schema-aware') would not return false, because you would never get as far as executing it - the xsl:import-schema declaration would be rejected as a static error.

So I'm not really clear what you are trying to achieve, I'm afraid.

Michael Kay
Saxonica

On 28 Sep 2016, at 14:37, [hidden email] wrote:

Hi,

Is it possible to have an enterprise processor:

new Processor(true)

and run a transform where system-property('xsl:is-schema-aware') returns false, even when the xslt contains <xsl:import-schema> ?

I ask because I want to run some 3rd party xslt 2.0s which use result validation during their testing, but not in prod, in the same processor that runs some xslt 3.0 code...   It seems that xsl:import-schema overrides any configuration I set?

Using Saxon EE 9.6.0.9.

Andrew1 WELCH
XML Developer | Finance & Regulatory IT | HSBC BANK PLC HBEU
8 Canada Square,Canary Wharf,London,E14 5HQ,United Kingdom
__________________________________________________________

Phone 0207 991 9571
Mobile 07717 684 177
Email [hidden email]


__________________________________________________________
Protect our environment - please only print this if you have to!



************************************************************
HSBC Bank plc may be solicited in the course of its placement efforts for a new issue, by investment clients of the firm for whom the Bank as a firm already provides other services. It may equally decide to allocate to its own proprietary book or with an associate of HSBC Group. This represents a potential conflict of interest. HSBC Bank plc has internal arrangements designed to ensure that the firm would give unbiased and full advice to the corporate finance client about the valuation and pricing of the offering as well as internal systems, controls and procedures to identify and manage conflicts of interest.

HSBC Bank plc
Registered Office: 8 Canada Square, London E14 5HQ, United Kingdom
Registered in England - Number 14259
Authorised by the Prudential Regulation Authority and regulated by the Financial Conduct Authority and the Prudential Regulation Authority
************************************************************


-----------------------------------------
SAVE PAPER - THINK BEFORE YOU PRINT!

This E-mail is confidential. 

It may also be legally privileged. If you are not the addressee you may not copy,
forward, disclose or use any part of it. If you have received this message in error,
please delete it and all copies from your system and notify the sender immediately by
return E-mail.

Internet communications cannot be guaranteed to be timely secure, error or virus-free.
The sender does not accept liability for any errors or omissions.

------------------------------------------------------------------------------
_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help


------------------------------------------------------------------------------

_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help 
Reply | Threaded
Open this post in threaded view
|

Re: Disabling schema awareness in an enterprise processor when xsl:import-schema is present in the xslt

andrew1.welch
Yes sorry it wasn't a great explanation... I'll try again:

Imagine an xslt 2.0 stylesheet which uses many java extension functions, and result validation via this approach:

    <xsl:import-schema schema-location="../XSD/FpML_5.5/recordkeeping/fpml-main-5-5.xsd"
                       use-when="system-property('xsl:is-schema-aware')='yes'"/>

    <xsl:template match="/">
        <xsl:apply-templates/>
    </xsl:template>

    <xsl:template match="/" priority="2"
                  use-when="system-property('xsl:is-schema-aware')='yes'">

        <xsl:result-document validation="strict">
            <xsl:apply-templates/>
        </xsl:result-document>
    </xsl:template>

This runs fine in 9.1.0.8 Basic, which allows the extension function calls, and ignores the schema aware aspect (which is used by the devs when working in the IDE where an SA processor is inbuilt).

I'm now trying to run these 3rd party xslts (of which there are many) with 9.6.0.9 EE.   I think I need to use new Processor(true) in order to allow the extension functions, but then it always tries to resolve the import-schema.   Even if I solve that via a custom uri resolver, I hit a namespace mismatch issue because the import-schema instruction is missing @targetNamespace.

So I was hoping to somehow continue with the enterprise config, but disable the schema awareness... it's just occurred to me that I might be able to solve this by lowering the version to PE instead of EE?  

Andrew1 WELCH
XML Developer | Finance & Regulatory IT | HSBC BANK PLC HBEU
8 Canada Square,Canary Wharf,London,E14 5HQ,United Kingdom
__________________________________________________________

Phone 0207 991 9571
Mobile 07717 684 177
Email andrew1.welch@...


__________________________________________________________
Protect our environment - please only print this if you have to!





From:        Michael Kay <[hidden email]>
To:        Mailing list for the SAXON XSLT and XQuery processor <[hidden email]>
Date:        28/09/2016 16:26
Subject:        Re: [saxon] Disabling schema awareness in an enterprise processor        when xsl:import-schema is present in the xslt




I fear that the answer is no.

The Javadoc for XsltCompiler.setSchemaAware() seems to describe the behaviour correctly

/**
* Say that the stylesheet must be compiled to be schema-aware, even if it contains no
* xsl:import-schema declarations. Normally a stylesheet is treated as schema-aware
* only if it contains one or more xsl:import-schema declarations. If it is not schema-aware,
* then all input documents must be untyped, and validation of temporary trees is disallowed
* (though validation of the final result tree is permitted). Setting the argument to true
* means that schema-aware code will be compiled regardless.
*
* @param
schemaAware If true, the stylesheet will be compiled with schema-awareness
*                    enabled even if it contains no xsl:import-schema declarations. If false, the stylesheet
*                    is treated as schema-aware only if it contains one or more xsl:import-schema declarations.


But even if you could do this, system-property('xsl:is-schema-aware') would not return false, because you would never get as far as executing it - the xsl:import-schema declaration would be rejected as a static error.

So I'm not really clear what you are trying to achieve, I'm afraid.

Michael Kay
Saxonica

On 28 Sep 2016, at 14:37, andrew1.welch@... wrote:

Hi,

Is it possible to have an enterprise processor:


new Processor(true)


and run a transform where system-property('xsl:is-schema-aware') returns false, even when the xslt contains <xsl:import-schema> ?


I ask because I want to run some 3rd party xslt 2.0s which use result validation during their testing, but not in prod, in the same processor that runs some xslt 3.0 code...   It seems that xsl:import-schema overrides any configuration I set?


Using Saxon EE 9.6.0.9.


Andrew1 WELCH

XML Developer | Finance & Regulatory IT | HSBC BANK PLC HBEU
8 Canada Square,Canary Wharf,London,E14 5HQ,United Kingdom
__________________________________________________________

Phone 0207 991 9571
Mobile 07717 684 177
Email andrew1.welch@...



__________________________________________________________

Protect our environment - please only print this if you have to!




************************************************************
HSBC Bank plc may be solicited in the course of its placement efforts for a new issue, by investment clients of the firm for whom the Bank as a firm already provides other services. It may equally decide to allocate to its own proprietary book or with an associate of HSBC Group. This represents a potential conflict of interest. HSBC Bank plc has internal arrangements designed to ensure that the firm would give unbiased and full advice to the corporate finance client about the valuation and pricing of the offering as well as internal systems, controls and procedures to identify and manage conflicts of interest.

HSBC Bank plc
Registered Office: 8 Canada Square, London E14 5HQ, United Kingdom
Registered in England - Number 14259
Authorised by the Prudential Regulation Authority and regulated by the Financial Conduct Authority and the Prudential Regulation Authority
************************************************************



-----------------------------------------
SAVE PAPER - THINK BEFORE YOU PRINT!

This E-mail is confidential.  

It may also be legally privileged. If you are not the addressee you may not copy,
forward, disclose or use any part of it. If you have received this message in error,
please delete it and all copies from your system and notify the sender immediately by
return E-mail.

Internet communications cannot be guaranteed to be timely secure, error or virus-free.
The sender does not accept liability for any errors or omissions.


------------------------------------------------------------------------------
_______________________________________________
saxon-help mailing list archived at
http://saxon.markmail.org/
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help


***************************************************
This message originated from the Internet. Its originator
may or may not be who they claim to be and the information
contained in the message and any attachments may or may
not be accurate.
****************************************************

 

------------------------------------------------------------------------------


***************************************************
This message originated from the Internet. Its originator
may or may not be who they claim to be and the information
contained in the message and any attachments may or may
not be accurate.
****************************************************
_______________________________________________
saxon-help mailing list archived at
http://saxon.markmail.org/
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help


************************************************************
HSBC Bank plc may be solicited in the course of its placement efforts for a new issue, by investment clients of the firm for whom the Bank as a firm already provides other services. It may equally decide to allocate to its own proprietary book or with an associate of HSBC Group. This represents a potential conflict of interest. HSBC Bank plc has internal arrangements designed to ensure that the firm would give unbiased and full advice to the corporate finance client about the valuation and pricing of the offering as well as internal systems, controls and procedures to identify and manage conflicts of interest.

HSBC Bank plc
Registered Office: 8 Canada Square, London E14 5HQ, United Kingdom
Registered in England - Number 14259
Authorised by the Prudential Regulation Authority and regulated by the Financial Conduct Authority and the Prudential Regulation Authority
************************************************************


-----------------------------------------
SAVE PAPER - THINK BEFORE YOU PRINT!

This E-mail is confidential. 

It may also be legally privileged. If you are not the addressee you may not copy,
forward, disclose or use any part of it. If you have received this message in error,
please delete it and all copies from your system and notify the sender immediately by
return E-mail.

Internet communications cannot be guaranteed to be timely secure, error or virus-free.
The sender does not accept liability for any errors or omissions.


------------------------------------------------------------------------------

_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help 
Reply | Threaded
Open this post in threaded view
|

Re: Disabling schema awareness in an enterprise processor when xsl:import-schema is present in the xslt

Michael Kay
In XSLT 3.0 you could control the use-when using static parameters, but that will be rejected in HE, unfortunately. Ditto environment-variable(). But you could use system-property('xslt.schema.aware') to read a Java system property:


Would that do the trick? The only potential issue is that Java system properties are rather too widely scoped.

Another option I have seen used is to use the structure:

A.xsl

xsl:stylesheet
   xsl:import-schema
   xsl:import href=B.xsl
   xsl:template match="/"
     xsl:document validation='strict'
        xsl:next-match
     /xsl:document
   /xsl:template
/xsl:stylesheet

B.xsl
xsl:stylesheet
   xsl:template match="/"
   /xsl:template
/xsl:stylesheet

and then run A.xsl or B.xsl depending on whether you want the schema validation.

Finally, note that you can import schemas from the command line or API as an alternative to doing it from the stylesheet, and you can also control result tree validation at the s9api level by setting a SchemaValidator as the Destination of the XsltTransformer.

Michael Kay
Saxonica

On 28 Sep 2016, at 16:54, [hidden email] wrote:

Yes sorry it wasn't a great explanation... I'll try again:

Imagine an xslt 2.0 stylesheet which uses many java extension functions, and result validation via this approach:

    <xsl:import-schema schema-location="../XSD/FpML_5.5/recordkeeping/fpml-main-5-5.xsd"
                       use-when="system-property('xsl:is-schema-aware')='yes'"/>

    <xsl:template match="/">
        <xsl:apply-templates/>
    </xsl:template>

    <xsl:template match="/" priority="2"
                  use-when="system-property('xsl:is-schema-aware')='yes'">

        <xsl:result-document validation="strict">
            <xsl:apply-templates/>
        </xsl:result-document>
    </xsl:template>

This runs fine in 9.1.0.8 Basic, which allows the extension function calls, and ignores the schema aware aspect (which is used by the devs when working in the IDE where an SA processor is inbuilt).

I'm now trying to run these 3rd party xslts (of which there are many) with 9.6.0.9 EE.   I think I need to use new Processor(true) in order to allow the extension functions, but then it always tries to resolve the import-schema.   Even if I solve that via a custom uri resolver, I hit a namespace mismatch issue because the import-schema instruction is missing @targetNamespace.

So I was hoping to somehow continue with the enterprise config, but disable the schema awareness... it's just occurred to me that I might be able to solve this by lowering the version to PE instead of EE?  

Andrew1 WELCH
XML Developer | Finance & Regulatory IT | HSBC BANK PLC HBEU
8 Canada Square,Canary Wharf,London,E14 5HQ,United Kingdom
__________________________________________________________

Phone 0207 991 9571
Mobile 07717 684 177
Email [hidden email]


__________________________________________________________
Protect our environment - please only print this if you have to!





From:        Michael Kay <[hidden email]>
To:        Mailing list for the SAXON XSLT and XQuery processor <[hidden email]>
Date:        28/09/2016 16:26
Subject:        Re: [saxon] Disabling schema awareness in an enterprise processor        when xsl:import-schema is present in the xslt




I fear that the answer is no.

The Javadoc for XsltCompiler.setSchemaAware() seems to describe the behaviour correctly

/**
* Say that the stylesheet must be compiled to be schema-aware, even if it contains no
* xsl:import-schema declarations. Normally a stylesheet is treated as schema-aware
* only if it contains one or more xsl:import-schema declarations. If it is not schema-aware,
* then all input documents must be untyped, and validation of temporary trees is disallowed
* (though validation of the final result tree is permitted). Setting the argument to true
* means that schema-aware code will be compiled regardless.
*
* @param
schemaAware If true, the stylesheet will be compiled with schema-awareness
*                    enabled even if it contains no xsl:import-schema declarations. If false, the stylesheet
*                    is treated as schema-aware only if it contains one or more xsl:import-schema declarations.


But even if you could do this, system-property('xsl:is-schema-aware') would not return false, because you would never get as far as executing it - the xsl:import-schema declaration would be rejected as a static error.

So I'm not really clear what you are trying to achieve, I'm afraid.

Michael Kay
Saxonica

On 28 Sep 2016, at 14:37, [hidden email] wrote:

Hi,

Is it possible to have an enterprise processor:


new Processor(true)


and run a transform where system-property('xsl:is-schema-aware') returns false, even when the xslt contains <xsl:import-schema> ?


I ask because I want to run some 3rd party xslt 2.0s which use result validation during their testing, but not in prod, in the same processor that runs some xslt 3.0 code...   It seems that xsl:import-schema overrides any configuration I set?


Using Saxon EE 9.6.0.9.


Andrew1 WELCH

XML Developer | Finance & Regulatory IT | HSBC BANK PLC HBEU
8 Canada Square,Canary Wharf,London,E14 5HQ,United Kingdom
__________________________________________________________

Phone 0207 991 9571
Mobile 07717 684 177
Email [hidden email]



__________________________________________________________

Protect our environment - please only print this if you have to!




************************************************************
HSBC Bank plc may be solicited in the course of its placement efforts for a new issue, by investment clients of the firm for whom the Bank as a firm already provides other services. It may equally decide to allocate to its own proprietary book or with an associate of HSBC Group. This represents a potential conflict of interest. HSBC Bank plc has internal arrangements designed to ensure that the firm would give unbiased and full advice to the corporate finance client about the valuation and pricing of the offering as well as internal systems, controls and procedures to identify and manage conflicts of interest.

HSBC Bank plc
Registered Office: 8 Canada Square, London E14 5HQ, United Kingdom
Registered in England - Number 14259
Authorised by the Prudential Regulation Authority and regulated by the Financial Conduct Authority and the Prudential Regulation Authority
************************************************************



-----------------------------------------
SAVE PAPER - THINK BEFORE YOU PRINT!

This E-mail is confidential.  

It may also be legally privileged. If you are not the addressee you may not copy,
forward, disclose or use any part of it. If you have received this message in error,
please delete it and all copies from your system and notify the sender immediately by
return E-mail.

Internet communications cannot be guaranteed to be timely secure, error or virus-free.
The sender does not accept liability for any errors or omissions.


------------------------------------------------------------------------------
_______________________________________________
saxon-help mailing list archived at
http://saxon.markmail.org/
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help


***************************************************
This message originated from the Internet. Its originator
may or may not be who they claim to be and the information
contained in the message and any attachments may or may
not be accurate.
****************************************************

 

------------------------------------------------------------------------------


***************************************************
This message originated from the Internet. Its originator
may or may not be who they claim to be and the information
contained in the message and any attachments may or may
not be accurate.
****************************************************
_______________________________________________
saxon-help mailing list archived at
http://saxon.markmail.org/
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help


************************************************************
HSBC Bank plc may be solicited in the course of its placement efforts for a new issue, by investment clients of the firm for whom the Bank as a firm already provides other services. It may equally decide to allocate to its own proprietary book or with an associate of HSBC Group. This represents a potential conflict of interest. HSBC Bank plc has internal arrangements designed to ensure that the firm would give unbiased and full advice to the corporate finance client about the valuation and pricing of the offering as well as internal systems, controls and procedures to identify and manage conflicts of interest.

HSBC Bank plc
Registered Office: 8 Canada Square, London E14 5HQ, United Kingdom
Registered in England - Number 14259
Authorised by the Prudential Regulation Authority and regulated by the Financial Conduct Authority and the Prudential Regulation Authority
************************************************************



-----------------------------------------
SAVE PAPER - THINK BEFORE YOU PRINT!

This E-mail is confidential. 

It may also be legally privileged. If you are not the addressee you may not copy,
forward, disclose or use any part of it. If you have received this message in error,
please delete it and all copies from your system and notify the sender immediately by
return E-mail.

Internet communications cannot be guaranteed to be timely secure, error or virus-free.
The sender does not accept liability for any errors or omissions.

------------------------------------------------------------------------------
_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help


------------------------------------------------------------------------------

_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help