Subject: [xsl] xsl and <Div> tags - urgent please help From: "Aparna Konduri" <a_konduri@xxxxxxxxx> Date: Thu, 23 May 2002 10:27:50 -0400 |
Hi, I have an xml file generated for a C# class from Visual Studio. E.g: <member name="T:Person"> <access type="public"/> <summary> Person class </summary> </member> <member name="M:getName()"> <access type="public"/> <summary> get name method </summary> </member> <member name="T:Car"> <access type="private"/> <summary> Car class </summary> </member> <member name="M:getMake()"> <access type="private"/> <summary> get make method </summary> </member> As you see, all the classes and its methods are shown as member tags. Only thing that differentiates the two is the first character of the name value (e.g. "T" for class type, "M" for method). I use an xsl file as attached to display the xml. But I want the toggling functionality on each class shown on html page. i.e. if I click on the classname, its body and methods should appear. If I click again they should disappear. I could get it to work if xml file has single class information. If I have multiple classes in the xml, how should I have my <div> tags in xsl file, so that only that class is affected? I mean <div> tag should start when class starts, and ends after all its methods, fields, properties end. In my xsl file, I started a <DIV> tag when classs started, and I tried to close it when a new class is about to start. I am running into a problem here as the xsl;Script doesn't recognize </Div> tag and complains "End DIV tag doesn't match xsl:script tag". Please see my xsl file: <!-- <?xml:stylesheet href="XMLDocumentation.xsl" type="text/xsl"?> <xsl:output method = "html"/> --> <xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl"> <xsl:script> var nodeInfo = null; var prevNodeInfo; //Checks if the member tag refers to a class function isType(node) { prevNodeInfo = nodeInformation; var isType = (node.getAttribute("name").charAt(0) == 'T'); if(isType) { fullName(this); } return isType; } //Checks if the member tag refers to a method function isMethod(node) { var name = node.getAttribute("name"); var isMethod; if( name.indexOf("op_") >= 0 ) return false; else { isMethod = (node.getAttribute("name").charAt(0) == 'M'); if(isMethod) memberName(this); return isMethod; } } // Display the member tags only when they refer to public classes/ methods function isDisplayed(node) { var accNode = node.getElementsByTagName("access").item(0); var type = accNode.getAttribute("type"); if(type == "public") return true; else return false; } function fullName(node) { nodeInfo = node.getAttribute("name").substr(2); nodeInformation = nodeInfo; return nodeInfo; } function memberName(node) { var name = node.getAttribute("name").substr(2); var p = name.indexOf("#ctor"); if (p >= 0) { basename = name.substr(0, p - 1); var params = name.substr(p + 5); if (params == "") params = "()"; nodeInfo = basename.substr(basename.lastIndexOf(".") + 1) + params; return nodeInfo; } else { var p = name.indexOf("("); var params; var basename; if (p == -1) p = name.length + 1; basename = name.substr(0, p); var member = basename.substr(basename.lastIndexOf(".") + 1); nodeInfo = member + name.substr(p); return nodeInfo; } } </xsl:script> <xsl:template match="/"> <xsl:apply-templates select="doc"/> </xsl:template> <xsl:template match="doc"> <HTML> <HEAD> <TITLE><xsl:value-of select="assembly/name"/> </TITLE> <LINK rel="stylesheet" type="text/css" href="doc.css"/> </HEAD> <BODY> <xsl:apply-templates select="members/member"/> </BODY> </HTML> </xsl:template> <xsl:template match="member"> <xsl:choose> <xsl:when expr="isType(this)"> <xsl:if test="access"> <xsl:choose> <xsl:when expr="isDisplayed(this)"> <xsl:script> if(prevNodeInfo != null) document.write("<\/DIV>"); </xsl:script> <a href="#" onClick = "if( window.document.all.item(nodeInfo.toString()) .style.visibility == 'visible') { window.document.all.item(nodeInfo.toString()) .style.visibility == 'hidden'; } else { window.document.all.item(nodeInfo.toString()).style.visibility == 'visible'; } "> <h1> <xsl:eval>nodeInfo</xsl:eval> </h1> </a> <msxsl:script> document.write("<DIV id=" +nodeInfo +">");</msxsl:script> <xsl:apply-templates select="summary"/> <xsl:apply-templates select="remarks"/> <xsl:apply-templates select="example"/> <xsl:if test="seealso"> <h4>See Also</h4> <xsl:apply-templates select="seealso"/> </xsl:if> <xsl:apply-templates select="members/member"/> </xsl:when> </xsl:choose> </xsl:if> </xsl:when> <xsl:when expr="isMethod(this)"> <xsl:if test="access"> <xsl:choose> <xsl:when expr="isDisplayed(this)"> <h2> <xsl:eval>nodeInfo</xsl:eval> method</h2> <xsl:apply-templates select="summary"/> </xsl:when> </xsl:choose> </xsl:if> </xsl:when> </xsl:stylesheet> Thanks in advance. Ana ________________________________________________________ Outgrown your current e-mail service? Get a 25MB Inbox, POP3 Access, No Ads and No Taglines with LYCOS MAIL PLUS. http://login.mail.lycos.com/brandPage.shtml?pageId=plus XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] large spaces between tabl, J.Pietschmann | Thread | Re: [xsl] xsl and <Div> tags - urge, Jeni Tennison |
[xsl] large spaces between table ce, \"Anth Courtney\" | Date | [xsl] Same TAG name ?, longjohn |
Month |