O'Reilly Forums: Week 5 Homework: Partial View Of Each Narrative - O'Reilly Forums

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Week 5 Homework: Partial View Of Each Narrative Specifying which element values to show

#1 User is offline   jyurow 

  • Active Member
  • PipPip
  • Group: Members
  • Posts: 31
  • Joined: 02-November 10

Posted 20 November 2010 - 07:50 PM

I wanted to show the values of all para, image, and photoReference elements, but none other, for each of the narratives, separating the narratives with horizontal lines. I was able to come up with a solution that works and wanted to share it with the class.

First, I removed the [id='@(specific id)'] clause to get all narratives instead of a specific narrative.

Second, I modified the tag: <xsl:apply-templates select="description"/> to read

<xsl:apply-templates select="description[descendant::para|descendant::image|descendant::photoReference]"/>. (Oxygen suggested "descendant::" and I guessed that "|" might be the symbol for "or.")

This worked fine for all the narratives but one, "narr_walk_butt". This narrative has three photoReference tags in succession, the values of which the transformation processor concatenated onto a single line. The reason for this is that Bob's template library BodyElements.xsl contains no template for the photoReference element. It seems that the XSL processor used a default "value-of" template to simply extract the three photoReference values and produced this messy result.

To remedy this, I added an additional template to the BodyElements.xsl file that reads:

<xsl:template match="photoReference">
<p><xsl:value-of select="."/></p>
</xsl:template>
</xsl:stylesheet>

This causes the last three photoReference values in id="narr_walk_butt" to appear on three separate lines, within <p></p> tags, as I think they should.

This post has been edited by jyurow: 20 November 2010 - 07:51 PM

0

#2 User is offline   jyurow 

  • Active Member
  • PipPip
  • Group: Members
  • Posts: 31
  • Joined: 02-November 10

Posted 23 November 2010 - 08:38 AM

After watching the Week 6 class, I changed the value of the select attribute to read:

select="//narrative//para|//narrative//image|//narrative//photoReference"

This also works, but has the advantage of being something that Bob demonstrated in class, rather than the more advanced:

select="description[descendant::para|descendant::image|descendant::photoReference]", which was something that Oxygen happened to suggest.



0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users