[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Avoiding selection of UNREQUESTED elements?

Subject: Re: Avoiding selection of UNREQUESTED elements?
From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx>
Date: Thu, 28 Jun 2001 12:24:53 +0100
access distict
Hi Simon,

At 10:04 AM 6/28/01, you wrote:
Hello

can anyone help me with a simple problem, i think!!

[snip]


 The problem i have is that i cant access 1 distict record, without
pulling out data from nodes that are NOT required. I am sure it is
something to do with the contextual node?? however cant work it out!!!

Here's the xsl file.

<xsl:template match="clientlog/customer">

    <xsl:value-of select="@customerid[.='bloggs']"/>
    <xsl:value-of select="//logitem/@logid"/>
    <xsl:value-of select="logitem/date"/>
    <xsl:value-of select="logitem/message"/>
    <xsl:value-of select="logitem/contact/@contactname"/>
</xsl:template>
</xsl:stylesheet>

The only thing you're doing wrong is not accounting for the ordinary operation of the built-in templates, whose job it is to make sure that unless you say otherwise, all data will be copied into the result tree.


A simple way to fix this is by adding a template to match at the top of your tree, selecting only the nodes you want, as in:

<xsl:template match="/"> <!-- matches the root -->
  <xsl:apply-templates select="//clientlog/customer"/>
  <!-- reaches "into" the tree and selects only the nodes you want -->
</xsl:template>

Then your other template does the rest.

At least, that's what I *think* the problem is. (I'm reading between the lines a little. Please forgive me if it's not. If it is, you might want to take some time to study the XSLT processing model and learn what those built-in templates do.)

Good luck,
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



Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.