Re: [xsl]Problem with Position()?

Subject: Re: [xsl]Problem with Position()?
From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx>
Date: Sat, 13 Oct 2007 15:37:29 -0400
At 2007-10-13 15:25 -0400, Alice Ju-Hsuan Wei wrote:
there is a new problem. I have a "id()" function embedded in my document that goes along in my document which is now not displaying no matter if I used Saxon 8 or XSLT proc. With 8, it tells me this error: Description: An attribute node (class) cannot be created after the children of the containing element. What I am supposed to have is some kind of display of who recorded the item.

Your error is being triggered somewhere other than the code you cut and pasted into your posting.


The error is quite explicit: somewhere you are adding an attribute to the result tree, but at the time you are doing so you have already added child nodes to the most recently added element. You can only add attributes to an element before you start adding the elements children.

Nowhere in the code you posted are you adding an attribute to an element, so the problem is elsewhere.

XSLT:

<xsl:template match="collection">
  <div><p/>
           <span class="character">
               <xsl:apply-templates select="id(@recorder)"/>
</span>
</div>
</xsl:template>

<xsl:template match="book">

<div>
  <xsl:apply-templates select="./@author"/>,
  <i><xsl:apply-templates select="./@title"/></i>.
   (<xsl:apply-templates select="./@topic"/>)

My guess is that it might be there, where you are pushing the topic attribute. How are you handling the matching of the topic attribute? If when you catch it you are adding it to the result tree, then that is not a valid place to do so because the last thing added to the result tree is the left parenthesis in the text node, not an element.


But that is just a guess since you don't have everything exposed in your post.

I hope this helps.

. . . . . . . . . . . . . . . . Ken


-- Comprehensive in-depth XSLT2/XSL-FO1.1 classes: Austin TX,Jan-2008 World-wide corporate, govt. & user group XML, XSL and UBL training RSS feeds: publicly-available developer resources and training G. Ken Holman mailto:gkholman@xxxxxxxxxxxxxxxxxxxx Crane Softwrights Ltd. http://www.CraneSoftwrights.com/s/ Box 266, Kars, Ontario CANADA K0A-2E0 +1(613)489-0999 (F:-0995) Male Cancer Awareness Jul'07 http://www.CraneSoftwrights.com/s/bc Legal business disclaimers: http://www.CraneSoftwrights.com/legal

Current Thread