xsl-list
[Top] [All Lists]

Re: [xsl] would like to simplify my XSLT

2007-01-29 20:15:08
--- Abel Braaksma <abel(_dot_)online(_at_)xs4all(_dot_)nl> wrote:

Abel Braaksma wrote:

You are using translate(), which hints (imo) that
you are using XSLT 
1. Can you confirm? Or do you use XSLT 2 (this
highly influences the 
answers you will get)?

Here's one solution. I believe it will work on both
1.0 and 2.0, but I 
tested only 2.0.

    <xsl:template match="* | text()">
        <xsl:apply-templates />
    </xsl:template>


Newbie question here--but why do you match on "* |
text()" instead of just matching on "/"?  (I saw the
physical answer--by matching on the latter I got a lot
of strange white space--but I'm not sure why.)


    <xsl:template match="
                  person[document[
                  not(@relid =
                 
../../../documents/document/@id)]]">

        <person name="{name}" />
    </xsl:template>

It will output all persons that have at least one
not-matching @relid, 
like this, for your input:

<person name="Chris" />


That's correct, but this is not exactly what I needed.
 I wanted names of people who didn't have *any*
documents in the document list--Chris shouldn't appear
because he had one of his two documents there.

By removing the "not" in your XPATH above, that gave
me people who have at least one document in the
document list, useful but still not what I was looking
for.

I'll check the other responses to see if they will
help.


Your own code much resembles the way you may do it
in imperative 
languages like Java, PHP, VB or C. However, using
templates, you can let 
the processor do the math for you and you only have
to draw the rules.


I know -- I come from a Java background so that's how
my XSLT will currently look until I figure out how to
do things better!

Cheers,
-- Abel Braaksma
   http://www.nuntia.nl


Thanks much!
Glen



 
____________________________________________________________________________________
Finding fabulous fares is fun.  
Let Yahoo! FareChase search your favorite travel sites to find flight and hotel 
bargains.
http://farechase.yahoo.com/promo-generic-14795097

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--