Subject: Re: [xsl] How can I match some elements with cross-referencing? From: "Richard Kerry richard.kerry@xxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> Date: Tue, 16 Aug 2022 16:00:51 -0000 |
Thanks Martin. I'll look at using keys. I have previously heard of XSL keys but never had any cause to study how to use them until this. There seems to be a "mailto:" that's crept into your reply (or been added by my mail client). I guess that's someone's mail system deciding that '@' (intended to mean attribute) should have the meaning it has in email addresses. Richard. [Blue line] 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> [Atos logo] 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: Martin Honnen martin.honnen@xxxxxx <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> Sent: 16 August 2022 12:18 To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx <xsl-list@xxxxxxxxxxxxxxxxxxxxxx> Subject: Re: [xsl] How can I match some elements with cross-referencing? Caution! External email. Do not open attachments or click links, unless this email comes from a known sender and you know the content is safe. Am 16.08.2022 um 13:09 schrieb Richard Kerry richard.kerry@xxxxxxxx<mailto:richard.kerry@xxxxxxxx>: I am putting together an XSL stylesheet to convert the format of some XML files [1]. I have a situation where I think I need some sort of cross-referencing within the file for setting the template matches, but I dont know how I might achieve that. By that I mean that there are elements, lets call them type A, which use a regular expression in their match specs, and when found it is also necessary to find some related elements, type B, and rewrite them (or delete them). I would appreciate some advice on what sort of method to use for this. I think I can see three ways I might approach this. 1. On finding the type A element, its action includes finding the B element and rewriting it. This ties all the processing to one template match. 2. Two separate templates. One matches elements A and processes them. The other matches elements of type B and includes some kind of look-up of any corresponding type A element. 3. Extra passes. First pass to extract a list of names, and second pass to use that in the match spec, if possible. Im not sure whether the first of these is even possible. It includes one template match of an element rewriting another element entirely. Thats not XSLs usual model and I dont think it can be done, can it? If the second option is the way to go, how should I go about defining the B element match to include the cross reference, ie the search to establish whether there is a corresponding A element? There is not a 1:1 correspondence between the two types. Not all B elements have a corresponding A element. So, to make it more concrete, lets say we have some A elements like this: <A name=n1.u>Contents of A[n1]</A> <A name=n2.u>Contents of A[n2]</A> <A name=n3.u>Contents of A[n3]</A> And some B like this: <B reference=n1.u>Contents of B[n1]</B> <B reference=n2.u>Contents of B[n2]</B> <B reference=n3.u>Contents of B[n3]</B> Use a key e.g. <xsl:key name="a" match="A[matches(@name, (.+).u)]"<mailto:A[matches(@name,(.+).u)]> use="@name"/> and then e.g. <xsl:template match="B[key('a', @reference)]"/> XSL-List info and archive<https://eur01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww. mulberrytech.com%2Fxsl%2Fxsl-list&data=05%7C01%7Crichard.kerry%40atos.net%7C2 3fa0357435e4d144c0d08da7f790b2a%7C33440fc6b7c7412cbb730e70b0198d5a%7C0%7C0%7C 637962455107524322%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMz IiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=nLOeNPWOrdGCZICXDI0j7o Kkqqnom%2FndcNYsJTs5PWU%3D&reserved=0> EasyUnsubscribe<https://eur01.safelinks.protection.outlook.com/?url=http%3A%2 F%2Flists.mulberrytech.com%2Funsub%2Fxsl-list%2F2528992&data=05%7C01%7Crichar d.kerry%40atos.net%7C23fa0357435e4d144c0d08da7f790b2a%7C33440fc6b7c7412cbb730 e70b0198d5a%7C0%7C0%7C637962455107524322%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4w LjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata= EKhXH%2FtURy73KfBwvUJABzZVAkUe%2BFKD%2BtMCTIHk%2FmI%3D&reserved=0> (by email<>)
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] How can I match some elem, Martin Honnen martin | Thread | [xsl] Performance differences betwe, Edward Porter edward |
Re: [xsl] How can I match some elem, Martin Honnen martin | Date | [xsl] Performance differences betwe, Edward Porter edward |
Month |