Hi all
I have an xml document that lists all files and folders in a directory in content management server. Each item contains information on its "parent" item, and its own link. An item that is a "child" item would not appear as a node under its "parent" - but would appear on the same node level.
I need to build up a "tree view" (the format is not important at this stage) by seeing if an item's parent matches another item's link. I'm not at all familiar with xslt - and basically what I need to do is get a current item's parent and check through the whole xml document to see if there is another item with the same value for it's link.
Here is a (very small) snippet from the document:
Here is the XSLT I am currently using (flawed as it does not do the "child check" properly):
I am using an extenstion object to return various information for the document:
public class XsltExtensions
{
private string _PortalURL = "";
private string _PortalHost = "";
private System.Web.UI.Page page = new System.Web.UI.Page();
public XsltExtensions(string PortalURL)
{
_PortalURL = PortalURL;
UriBuilder uriBuilder = new UriBuilder(_PortalURL);
_PortalHost = uriBuilder.Host;
}
public string getInfo()
{
return "PORTAL URL ::: " + _PortalURL + " ::: PORTAL HOST ::: " + _PortalHost;
}
public string tolower(string FormatString)
{
return FormatString.ToLower();
}
public int checkChild(string ParentName, string Href)
{
ParentName = page.Server.UrlDecode(ParentName.Replace(".",_PortalHost).ToLower());
Href = page.Server.UrlDecode(Href).ToLower();
if (ParentName == Href)
{
//the string is contained in the URL
return 1;
}
else
{
//the string is not contained in the url
return 0;
}
}
public string checkParentName(string ParentName)
{
ParentName = page.Server.UrlDecode(ParentName.Replace(".",_PortalHost).ToLower());
return ParentName;
}
public string checkHref(string Href)
{
Href = page.Server.UrlDecode(Href).ToLower();
return Href;
}
}
The _PortalURL passed would be " Ideally the last item should appear under the top item and the middle item should appear under the last item (if my xslt worked correctly!).
Apologies for the length of this - if anyone could just please give me some guidelines on how to proceed I would be very appreciative!
Thanks as always
Craftor

I have an xml document that lists all files and folders in a directory in content management server. Each item contains information on its "parent" item, and its own link. An item that is a "child" item would not appear as a node under its "parent" - but would appear on the same node level.
I need to build up a "tree view" (the format is not important at this stage) by seeing if an item's parent matches another item's link. I'm not at all familiar with xslt - and basically what I need to do is get a current item's parent and check through the whole xml document to see if there is another item with the same value for it's link.
Here is a (very small) snippet from the document:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<a:multistatus xmlns:a="DAV:" xmlns:b="urn:uuid:c2f41010-65b3-11d1-a29f-00aa00c14882/" xmlns:c="xml:" xmlns:d="urn:schemas.microsoft.com:fulltextqueryinfo:" xmlns:e="urn:schemas-microsoft-com:office:office">
<a:response>
<a:href>[URL unfurl="true"]http://SPS/Production</a:href>[/URL]
<a:propstat>
<a:status>HTTP/1.1 200 OK</a:status>
<a:prop>
<a:isfolder b:dt="boolean">1</a:isfolder>
<a:displayname>Production</a:displayname>
<a:parentname>[URL unfurl="true"]http://.</a:parentname>[/URL]
<e:Title>Production</e:Title>
<e:Description>All production, R&D Files, etc</e:Description>
</a:prop>
</a:propstat>
</a:response>
<a:response> <a:href>[b][URL unfurl="true"]http://SPS/Production/Documents/Production%20Documentation/HannoverRe/Documentation%20and%20Manuals/Documentation/Hannov-Desig-2002-11-12-Hannover.doc[/URL][/b]</a:href>
<a:propstat>
<a:status>HTTP/1.1 200 OK</a:status>
<a:prop>
<a:isfolder b:dt="boolean">0</a:isfolder>
<a:displayname>Hannov-Desig-2002-11-12-Hannover.doc</a:displayname>
<a:parentname>[URL unfurl="true"]http://./Production/Documents/Production[/URL] Documentation/HannoverRe/Documentation and Manuals/Documentation</a:parentname>
<e:Title>Programming Style Document</e:Title>
<e:Author></e:Author>
<e:Description>
</e:Description>
</a:prop>
</a:propstat>
</a:response>
<a:href>[URL unfurl="true"]http://SPS/Production/Documents</a:href>[/URL]
<a:propstat>
<a:status>HTTP/1.1 200 OK</a:status>
<a:prop>
<a:isfolder b:dt="boolean">1</a:isfolder>
<a:displayname>Documents</a:displayname>
<a:parentname>[URL unfurl="true"]http://./Production</a:parentname>[/URL]
<e:Title>Documents</e:Title>
<e:Description>
</e:Description>
</a:prop>
</a:propstat>
</a:response>
</a:multistatus>
Here is the XSLT I am currently using (flawed as it does not do the "child check" properly):
Code:
<xsl:stylesheet version="1.0"
xmlns:a="DAV:"
xmlns:xsl="[URL unfurl="true"]http://www.w3.org/1999/XSL/Transform"[/URL]
xmlns:e="urn:schemas-microsoft-com:office:office"
xmlns:extension="urn:extension">
<xsl:template match="a:multistatus">
<xsl:apply-templates select="a:response[a:propstat/a:status='HTTP/1.1 200 OK' and (a:propstat/a:prop/a:isfolder='1' or a:propstat/a:prop/a:isfolder=1) ]"/>
</xsl:template>
<xsl:template match="a:response">
<xsl:param name="href" select="a:href"/>
<p><b>Parent Name:</b> <xsl:value-of select="a:propstat/a:prop/a:parentname" /> :::: <xsl:value-of select="extension:checkParentName(a:propstat/a:prop/a:parentname)" /> </p>
<p><b>Href:</b> <xsl:value-of select="$href" /> :::: <xsl:value-of select="extension:checkHref($href)" /></p>
<p>Info: <xsl:value-of select="extension:getInfo()" /></p>
<p>Display name: <xsl:value-of select="a:propstat/a:prop/a:displayname" /> +++ CheckChild: <xsl:value-of select="extension:checkChild(a:propstat/a:prop/a:parentname, $href)" /></p>
<xsl:apply-templates select="a:response[a:propstat/a:status='HTTP/1.1 200 OK' and (a:propstat/a:prop/a:isfolder='1' or a:propstat/a:prop/a:isfolder=1) and extension:checkChild(a:propstat/a:prop/a:parentname, $href)=1]"/>
<xsl:apply-templates select="a:response[a:propstat/a:status='HTTP/1.1 200 OK' and (a:propstat/a:prop/a:isfolder='0' or a:propstat/a:prop/a:isfolder=0) and extension:checkChild(a:propstat/a:prop/a:parentname, $href)=1]"/>
</xsl:template>
</xsl:stylesheet>
I am using an extenstion object to return various information for the document:
public class XsltExtensions
{
private string _PortalURL = "";
private string _PortalHost = "";
private System.Web.UI.Page page = new System.Web.UI.Page();
public XsltExtensions(string PortalURL)
{
_PortalURL = PortalURL;
UriBuilder uriBuilder = new UriBuilder(_PortalURL);
_PortalHost = uriBuilder.Host;
}
public string getInfo()
{
return "PORTAL URL ::: " + _PortalURL + " ::: PORTAL HOST ::: " + _PortalHost;
}
public string tolower(string FormatString)
{
return FormatString.ToLower();
}
public int checkChild(string ParentName, string Href)
{
ParentName = page.Server.UrlDecode(ParentName.Replace(".",_PortalHost).ToLower());
Href = page.Server.UrlDecode(Href).ToLower();
if (ParentName == Href)
{
//the string is contained in the URL
return 1;
}
else
{
//the string is not contained in the url
return 0;
}
}
public string checkParentName(string ParentName)
{
ParentName = page.Server.UrlDecode(ParentName.Replace(".",_PortalHost).ToLower());
return ParentName;
}
public string checkHref(string Href)
{
Href = page.Server.UrlDecode(Href).ToLower();
return Href;
}
}
The _PortalURL passed would be " Ideally the last item should appear under the top item and the middle item should appear under the last item (if my xslt worked correctly!).
Apologies for the length of this - if anyone could just please give me some guidelines on how to proceed I would be very appreciative!
Thanks as always
Craftor