Subject: RE: selecting a node without its children From: Scott Zarecor <szarecor@xxxxxxxxxxxxxxxxxxxx> Date: Thu, 30 Mar 2000 16:49:39 -0500 |
Thanks for your thoughtful remarks. My problem was that I was trying to use 'text()' inside of: <xsl:for-each select="*"></xsl:for-each> rather than inside of <xsl:for-each select="."></xsl:for-each> That change made all the difference. I tend to agree with you that my data model might not be the best. I was suspicious of this sort of structure the first time I saw it in a XML document (one of Bosak's Shakespeare mark-ups), but now I appreciate some of the flexibility it offers. ~Scott -----Original Message----- From: David_Marston@xxxxxxxxx [mailto:David_Marston@xxxxxxxxx] Sent: Thursday, March 30, 2000 2:54 PM To: xsl-list@xxxxxxxxxxxxxxxx Subject: RE: selecting a node without its children Scott Zarecor wrote: > ...Here's what my XML looks like: > <task> > <author>Scott Zarecor</author> > <date>03/27/00</date> > The text of the task would go here... > </task> > Using '<xsl:apply-templates select="text()"/>' and other variations upon the > 'text()'-theme (with Xalan) returns the contents of the child nodes as well > as the text I'm actually after. Any ideas? > ~Scott Are you using the 1.0.0 release of Xalan? When the current node is <task>, <xsl:apply-templates select="text()"/> should select only the text nodes, including the interstitial ones before and after <author>. Mind you, my test had a template with match="*" so I could catch child elements separately from the text nodes. This should work equally well with <xsl:for-each select="text()"/> if you don't want a separate template and shifting context. The remark about interstitial text nodes leads to a warning that the design you seem to be using makes it hard to grab the "text of the task" readily. If you can change this design, either of the following is better XML (IMHO): 1. Wrap the "text of the task" in a <description> element. 2. Make the text be the only content of <task>, moving author and date to attributes of <task>. I'll espouse the principle that content you wish to process should be isolated as an attribute value or text content that is not intermixed with children. Right now, the human-language way to express the location of the task description is: the one text node inside <task> that's not just whitespace. That gets awkward. .................David Marston XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: selecting a node without its ch, David_Marston | Thread | RE: selecting a node without its ch, Paal Eriksen |
Re: xsl question on fo:page-sequenc, Nikolai Grigoriev | Date | RE: variable values in for-each loo, Jonathan Asbell |
Month |