[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

How should I handle very similar templates ? Inserting

Subject: How should I handle very similar templates ? Inserting a string into a match spec ?
From: "Richard Kerry richard.kerry@xxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Thu, 20 Apr 2023 11:47:56 -0000
 How should I handle very similar templates ? Inserting
I am finding myself writing a number of templates that are almost identical,
differing only in strings within the match spec, and I'd like to reduce the
near-duplication, if it is possible.
I am filtering some Visual Studio project files to remove a certain
configuration and remove mentions of the remaining one.  The files include
elements that start as follows (slightly simplified, in case anyone familiar
with VS is saying "that's not quite right"):

  <PropertyGroup Condition="'$(Configuration)'=='Debug|Win32'" >

or

  <PropertyGroup Condition="'$(Configuration)'=='Release|Win32'" >

My task is to process one of these files and remove all references to either
Debug or Release.  I will remove all elements with the unwanted configuration,
and remove all the attributes that mention the wanted one.
I have templates to remove these elements, or to remove all the attriutes that
mention a particular configuration.
So one stylesheet contains a template to detect Release and remove all
elements (ie not copy them), and a template to remove all Debug configuration
attributes.

Templates are simple in that they do nothing in order to delete the element or
attribute from the output.

bbbbbb<xsl:template match="*[ @Condition =
'''$(Configuration)''==''Release|Win32''' ]" />

bbbbbb<xsl:template match="@Condition[ .=
'''$(Configuration)''==''Debug|Win32''' ]" />

Applying these two will remove all Release elements, and all mentions of Debug
from remaining elements.
I have another stylesheet that does the opposite, ie delete Debug elements and
Release attributes.

What I'd like to do is pass the keywords in as parameters; something like
bbbbbb<xsl:template match="*[ @Condition =
'''$(Configuration)''==''{$delete-element-name}|Win32''' ]" />

bbbbbb<xsl:template match="@Condition[ .=
'''$(Configuration)''==''{$delete-attribute-name}|Win32''' ]" />

with appropriate variables or parameters declared.  I tried a couple of
variants of the above, to no avail.
But I'm not even sure if this is possible.  Is it?  If it is possible but I
need to approach it differently, please can someone advise.

If this was C++ I'd just pass in strings and build the match specs
accordingly, or if it was more complex I'd put some logic in a class and pass
an object.



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.

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.