Subject: Re: [xsl] How do I pass the mode as a string? From: "Kerry, Richard richard.kerry@xxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> Date: Tue, 3 Mar 2020 16:25:16 -0000 |
Ok, so that's functions as things (I won't say "objects" as that may have implications). So I can define each apply-template in a separate function and then pass them as a "thing" to the file search action. That might be another option to try. Thank you. Regards, Richard. Richard Kerry BNCS Engineer, SI SOL Telco & Media Vertical Practice M: +44 (0)7812 325518 2nd Floor, MidCity Place, 71 High Holborn, London, WC1V 6EA richard.kerry@xxxxxxxx<https://webmail.siemens-it-solutions.com/owa/redir.asp x?C=9fb20d019e3e4cb99344d708709a3177&URL=mailto%3arichard.kerry%40atos.net> This e-mail and the documents attached are confidential and intended solely for the addressee; it may also be privileged. If you receive this e-mail in error, please notify the sender immediately and destroy it. As its integrity cannot be secured on the Internet, the Atos group liability cannot be triggered for the message content. Although the sender endeavours to maintain a computer virus-free network, the sender does not warrant that this transmission is virus-free and will not be liable for any damages resulting from any virus transmitted. ________________________________ From: Dimitre Novatchev dnovatchev@xxxxxxxxx <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> Sent: 03 March 2020 15:55 To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx <xsl-list@xxxxxxxxxxxxxxxxxxxxxx> Subject: Re: [xsl] How do I pass the mode as a string? Caution! Atos External email. Do not open attachments or click links, unless this email comes from a known sender and you know the content is safe. While this is not allowed in XSLT, one can accomplish the passing functions as parameters. For XSLT 1.0, 2.0 see the FXSL library. The XSLT 3.0 / XPath 3.0 and 3.1 standards support higher order functions. Cheers, Dimitre On Tue, Mar 3, 2020 at 3:20 AM Kerry, Richard richard.kerry@xxxxxxxx<mailto:richard.kerry@xxxxxxxx> <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx<mailto:xsl-list-service@xxxxxxxxxxxx rytech.com>> wrote: Normally I would specify apply-template's mode as a literal, eg: <x:apply-templates mode="inputs" /> I have a number of instances of similar code which need to have different modes, eg: <x:apply-templates mode="outputs" /> I'd like to extract all of this into a separate block that I will call with these two values. <x:variable name="match-mode" >inputs</x:variable> <x:apply-templates mode="$match-mode" /> Doesn't work. Saxon reports: Static error at x:apply-templates on line 47 column 74 of xxx.xsl: XTSE0020: Mode name {$match-mode} is not a valid QName OK, so it's a QName, not a string. So I try: <x:variable name="match-mode" as="xs:QName" >inputs</x:variable> <x:apply-templates mode="$match-mode" /> Again giving: Static error at x:apply-templates on line 47 column 74 of AlarmsAllToDot.xsl: XTSE0020: Mode name {$match-mode} is not a valid QName (xs is defined as xmlns:xs="http://www.w3.org/2001/XMLSchema<https://eur01.safelinks.protection .outlook.com/?url=http%3A%2F%2Fwww.w3.org%2F2001%2FXMLSchema&data=02%7C01%7Cr ichard.kerry%40atos.net%7C9ffba5a04fa84997385508d7bf8b74d7%7C33440fc6b7c7412c bb730e70b0198d5a%7C0%7C0%7C637188477985693934&sdata=YkfJHmOU2nc%2FQHsTjGOX4S% 2F8WkyW2DuuBznkNTtli4o%3D&reserved=0>" ) So just telling it to be a QName doesn't seem to work. I think this syntax for variable means 'inputs' is a text node, so what about: <x:variable name="match-mode" as="xs:QName" select="'inputs'" /> <x:apply-templates mode="$match-mode" /> So do I need to do something more actively to generate a QName? There is a QName function, so how about: <x:variable name="match-mode" as="xs:QName" select="QName('', 'inputs')" /> <x:apply-templates mode="$match-mode" /> Giving me the same error. So, where am I gong wrong? The QName function takes two strings, the first being the namespace. So is that wrong to be blank? Is "inputs" in my namespace? Or is it XSLT's? Given that this will be fed directly to apply-templates, presumably it needs to be in XSLT's, so how about: <x:variable name="match-mode" as="xs:QName" select="QName('x', 'inputs')" /> <x:apply-templates mode="$match-mode" /> (x is defined as xmlns:x="http://www.w3.org/1999/XSL/Transform<https://eur01.safelinks.protect ion.outlook.com/?url=http%3A%2F%2Fwww.w3.org%2F1999%2FXSL%2FTransform&data=02 %7C01%7Crichard.kerry%40atos.net%7C9ffba5a04fa84997385508d7bf8b74d7%7C33440fc 6b7c7412cbb730e70b0198d5a%7C0%7C0%7C637188477985693934&sdata=AX%2FY9FEUStORg9 Ixfp67P79b%2F30zJxxjDPdsb%2B9yMzg%3D&reserved=0>") Giving the same error. Or is this about how it is presented to apply-templates? Am I right to use mode="$match-mode", or should that be done differently? So, I've tried a few options but I suspect there's something important I'm missing about QNames and the mode attribute. Please can someone advise. Regards, Richard. -- Cheers, Dimitre Novatchev ---------------------------------------
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] How do I pass the mode as, Dimitre Novatchev dn | Thread | [xsl] How do I pass the mode as a s, Kerry, Richard richa |
Re: [xsl] How do I pass the mode as, Kerry, Richard richa | Date | Re: [xsl] How do I pass the mode as, Graydon graydon@xxxx |
Month |