0

Referencing from this source

Use ends with in XSLT v1.0

ends-with is not applicable in XPATH 1.0, but i need its function to work on my application.

This is the code snippet wherein i need to match a specific exact string

<xsl:template match="p:Project/p:ItemGroup/p:Reference[starts-with(@Include, 'Common')]/@Include">

In that line I tried modifying it to this to achieve the desired output, as per the exception "ends-with syntax is not part of XPATH 1.0"

 <xsl:template match="p:Project/p:ItemGroup/p:Reference[starts-with(@Include, 'Common') and ends-with(@Include, 'Common') ]/@Include">

Is there any alternative to do this?

I need to accomplish this, because there are parts in the xml file to be modified that has "Common" string in the beginning, like Common.UI, Common.Windows.Grid, so upon running, it also affects these lines

It should only change the one with "Common" only

rickyProgrammer
  • 1,177
  • 4
  • 27
  • 63
  • 1
    Unless I have misunderstood, if you are trying to "change the one with Common only", then you can just do `` – Tim C Nov 05 '18 at 09:52

1 Answers1

-1

The formula is already stated in the link that you have given. Since you are too lazy to analyze, please test the following:

<xsl:template match="p:Project/p:ItemGroup/p:Reference[starts-with(@Include, 'Common') and 'Common' = substring(@Include, string-length() - 5)]/@Include">
Joel M. Lamsen
  • 7,143
  • 1
  • 12
  • 14