1

I have these two arrays:

<xsl:variable name="array1" select="umbraco.library:Split($currentPage/websiteThemes, ',')//value"/>
<xsl:variable name="array2" select="umbraco.library:Split($currentPage/websiteThemes2, ',')//value"/>

I would like to see which elements inside the arrays which matches. How can I accomplish that?

This is the output from copy-of array1 and array2:

array1:

<value>1087</value><value>1002</value><value>3202</value>

array2:

<value>1087</value><value>1577</value>

In this example, I would like to get the value 1087 as my result.

1 Answer 1

2

The question isn't too-clear, but I hope that this answers what is being asked:

This transformation:

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
 <xsl:output omit-xml-declaration="yes" indent="yes"/>
 <xsl:strip-space elements="*"/>

 <xsl:variable name="vArr1" select="/*/arr1/*"/>
 <xsl:variable name="vArr2" select="/*/arr2/*"/>

 <xsl:template match="/">
     <xsl:copy-of select="$vArr1[. = $vArr2]"/>
 </xsl:template>
</xsl:stylesheet>

when applied on this XML document (none provided in the question!):

<t>
 <arr1>
  <value>1087</value>
  <value>1002</value>
  <value>3202</value>
 </arr1>
 <arr2>
  <value>1087</value>
  <value>1577</value>
 </arr2>
</t>

produces (what I guess is) the wanted result:

<value>1087</value>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.