Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><strong>This short and simple transformation:</strong></p> <pre><code>&lt;xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:x="http://microsoft.com/webservices/SharePointPortalServer/UserProfileService" exclude-result-prefixes="x"&gt; &lt;xsl:output omit-xml-declaration="yes" indent="yes"/&gt; &lt;xsl:key name="kGroupByVal" match="x:Group" use="."/&gt; &lt;xsl:template match= "x:Group[generate-id() = generate-id(key('kGroupByVal',.)[1])]"&gt; &lt;Group&gt; &lt;Value&gt;&lt;xsl:value-of select="."/&gt;&lt;/Value&gt; &lt;xsl:apply-templates select="key('kGroupByVal',.)/.." mode="inGroup"/&gt; &lt;/Group&gt; &lt;/xsl:template&gt; &lt;xsl:template match="x:QuickLinkData" mode="inGroup"&gt; &lt;Item&gt; &lt;ID&gt;&lt;xsl:value-of select="x:ID"/&gt;&lt;/ID&gt; &lt;Name&gt;&lt;xsl:value-of select="x:Name"/&gt;&lt;/Name&gt; &lt;Url&gt;&lt;xsl:value-of select="x:Url"/&gt;&lt;/Url&gt; &lt;/Item&gt; &lt;/xsl:template&gt; &lt;xsl:template match="text()"/&gt; &lt;/xsl:stylesheet&gt; </code></pre> <p><strong>when applied on the provided XML document:</strong></p> <pre><code>&lt;soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"&gt; &lt;soap:Body&gt; &lt;GetUserLinksResponse xmlns="http://microsoft.com/webservices/SharePointPortalServer/UserProfileService"&gt; &lt;GetUserLinksResult&gt; &lt;QuickLinkData&gt; &lt;Name&gt;System 1&lt;/Name&gt; &lt;Group&gt;General&lt;/Group&gt; &lt;Privacy&gt;Private&lt;/Privacy&gt; &lt;Url&gt;https://url1.com&lt;/Url&gt; &lt;ID&gt;6500&lt;/ID&gt; &lt;/QuickLinkData&gt; &lt;QuickLinkData&gt; &lt;Name&gt;System 2&lt;/Name&gt; &lt;Group&gt;General&lt;/Group&gt; &lt;Privacy&gt;Private&lt;/Privacy&gt; &lt;Url&gt;https://url2.com&lt;/Url&gt; &lt;ID&gt;6499&lt;/ID&gt; &lt;/QuickLinkData&gt; &lt;QuickLinkData&gt; &lt;Name&gt;System 3&lt;/Name&gt; &lt;Group&gt;Work&lt;/Group&gt; &lt;Privacy&gt;Private&lt;/Privacy&gt; &lt;Url&gt;http://url3.com&lt;/Url&gt; &lt;ID&gt;6845&lt;/ID&gt; &lt;/QuickLinkData&gt; &lt;/GetUserLinksResult&gt; &lt;/GetUserLinksResponse&gt; &lt;/soap:Body&gt; &lt;/soap:Envelope&gt; </code></pre> <p><strong>produces the wanted, correct result:</strong></p> <pre><code>&lt;Group&gt; &lt;Value&gt;General&lt;/Value&gt; &lt;Item&gt; &lt;ID&gt;6500&lt;/ID&gt; &lt;Name&gt;System 1&lt;/Name&gt; &lt;Url&gt;https://url1.com&lt;/Url&gt; &lt;/Item&gt; &lt;Item&gt; &lt;ID&gt;6499&lt;/ID&gt; &lt;Name&gt;System 2&lt;/Name&gt; &lt;Url&gt;https://url2.com&lt;/Url&gt; &lt;/Item&gt; &lt;/Group&gt; &lt;Group&gt; &lt;Value&gt;Work&lt;/Value&gt; &lt;Item&gt; &lt;ID&gt;6845&lt;/ID&gt; &lt;Name&gt;System 3&lt;/Name&gt; &lt;Url&gt;http://url3.com&lt;/Url&gt; &lt;/Item&gt; &lt;/Group&gt; </code></pre> <p><strong>Explanation</strong>:</p> <p>Proper use of the <strong><a href="http://www.jenitennison.com/xslt/grouping/muenchian.html" rel="nofollow">Muenchian Grouping Method</a></strong>.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload