[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Restrict Key to specific parent
Ty,
You don't want and can't use keys here, as keys by definition work across document-wide scope. What you do want looks fairly baroque, given your contingencies, but is actually simpler than trying to construct a key-based retrieval. For the name, just go grab the nodes you want using XPath, and write out their values. <xsl:template match="Name"> <xsl:for-each select="(ancestor::Profile|ancestor::Section|ancestor::Info)[last()]"> <!-- change context to the closest ancestor Profile, Section or Info --> <xsl:variable name="Prod-names" select="ProfileInfo/@name | Prod/@name"/> <!-- collect the ProfileInfo and Prod names (whichever you have here) --> <xsl:for-each select="$Prod-names[. = not(../preceding-sibling::*/@name)]"> <!-- iterate over this set, excluding duplicates (awkwardly, but better in this case than using a compound key to do it --> <xsl:value-of select="."/> <xsl:if test="not(position()=last())"> <!-- punctuate all but the last with a comma --> <xsl:text>, </xsl:text> </xsl:if> </xsl:for-each> </xsl:for-each> </xsl:template> This does rely quite heavily on your input being just as you describe. Both the node collection and the logic to remove duplicates (which you may not actually need, and should toss if not) are quite sensitive to your document structure being as you have presented it here. Cheers, Wendell At 02:44 PM 11/29/2006, you wrote: Hello, This is as simple of an example, hitting the main scenarios, I could come up with. ====================================================================== Wendell Piez mailto:wapiez@xxxxxxxxxxxxxxxx Mulberry Technologies, Inc. http://www.mulberrytech.com 17 West Jefferson Street Direct Phone: 301/315-9635 Suite 207 Phone: 301/315-9631 Rockville, MD 20850 Fax: 301/315-8285 ---------------------------------------------------------------------- Mulberry Technologies: A Consultancy Specializing in SGML and XML ======================================================================
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|