[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Stupid newbie question..
Hi Jordan,
At 02:16 PM 10/18/2002, you wrote: <?xml version="1.0"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method = "html" encoding="Windows-1252" /> You don't need that xsl:if test; rather, write a template matching "document/description" and output the title element there. If no such node exists, the template won't be matched. <body> <xsl:if test="document/content"> <xsl:apply-templates select="document/content" /> </xsl:if> For exactly the same reason, here the test is completely redundant. If document/content does not exist, no templates will be applied, so the apply-templates instruction by itself is sufficient. </body> </html> </xsl:template> So far, so good. <xsl:template match="one"> This is module one. </xsl:template> That template is your problem. You have no element <one>. Rather, you have an attribute named 'id' with *value* one. Try: <xsl:template match="attribute::id[.='one']"> This is module one. </xsl:template> Or even <xsl:template match="attribute::id"> This is module <xsl:value-of select="."/>. </xsl:template> Abbreviated XPath for "attribute::id" is "@id", which will work as well. BTW, on this list there are no "stupid newbie questions". Instead, from newbies we have either (a) very intelligent, probing questions intended to elicit the deep principles of XSL stylesheet design, or (b) requests for help getting over a hump early on the learning curve, or (c) requests for help with syntax from people too lazy or confused to look it up I'd put your question in category (b). Only (c) is less than welcome, and even there people usually get an answer (especially if they're apparently more confused than lazy). But we do like subject lines that will be informative to someone searching the archive. Here, "can a template match an attribute?" might be better than "Stupid newbie question". :-> Cheers, Wendell ====================================================================== 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 ====================================================================== XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
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
|