xsl-list
[Top] [All Lists]

RE: RE: [xsl] Isolating specific elements

2006-05-14 06:50:53
In my message I typed the "less than" symbol as ampersand lt semi-colon, but by 
the time it came back to my inbox, the display was "<". I don't know where the 
transformation happened, but be aware that it is illegal to use "<" as a 
comparison operator is XSLT. The XML Police are ever vigilant.
-- 
Charles Knell
cknell(_at_)onebox(_dot_)com - email



-----Original Message-----
From:     cknell(_at_)onebox(_dot_)com
Sent:     Sat, 13 May 2006 08:08:32 -0400
To:       xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject:  RE: [xsl] Isolating specific elements

This message has been sitting in my inbox for two days. I don't recall if 
anyone has answered, but if not, let me help.

Your string concatenation is way too complicated for me to give you a direct 
reply in the amount of time I'd care to spend, so let me give you a simplified 
example.

Suppose you have a series of elements like so:
<pets>
  <animal type="dog" breed="Cocker Spaniel"  weight="40" />
  <animal type="dog" breed="Great Dane" weight="80"/>
  <animal type="dog" breed="Shih Tzu" weight="3"/>
  <animal type="cat" breed="Siamese" weight="3"/>
  <animal type="cat" breed="Domestic Short Hair" weight="4"/>
  <animal type="cat" breed="Persian" weight="5"/>
</pets>

Say you want to select only those elements where type is "dog" and weight is 
less than "5". The key here is that you want nodes that match the first AND the 
second condition. You need to express both in your selection conditions.

<xsl:template match="/pets/animal[(_at_)type='dog' and @weight < 5]">
  <xsl:copy-of select="." />
</xsl:template>

The rest is left as an exercise for the reader.
-- 
Charles Knell
cknell(_at_)onebox(_dot_)com - email



-----Original Message-----
From:     Aaron Johnson <Aaron2(_dot_)Johnson(_at_)uwe(_dot_)ac(_dot_)uk>
Sent:     Thu, 11 May 2006 10:58:46 +0100
To:       "xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com" 
<xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com>
Subject:  [xsl] Isolating specific elements


Hello...

I have some xml...

<Item>
<workItemInstUrn>2076554</workItemInstUrn>
<workItemTitle>Future Item Future Item Future Item</workItemTitle>
<workItemCode>CW1</workItemCode>
<submissionDeadline>2007-05-10T14:00:00.0000000+01:00</submissionDeadline>
<releaseDate>2007-04-26T00:00:00.0000000+01:00</releaseDate>
<closureDate>2007-06-07T14:00:00.0000000+01:00</closureDate>
</Item>

I can sort through any <item> node and find submissionDeadline to test
against the current date but want to hide any <item> that has a releaseDate
greater than today's date.

The problem is my test picks up all <item> nodes and displays all because of
the submissionDeadline element.

Is there a way to test for both the release date and the submission date to
keep them excluded?

Here is my xsl...

<xsl:apply-templates select="//Item[concat(substring(submissionDeadline,
1,4),substring(submissionDeadline, 6,2),substring(submissionDeadline,
9,2),substring(submissionDeadline,12,2),substring(submissionDeadline,15,2),s
ubstring(submissionDeadline,18,2)) > $currentDateString]">
  
<xsl:sort select="submissionDeadline" order="descending"/>
<xsl:with-param name="display" >ontime</xsl:with-param>
</xsl:apply-templates>
<p class="errorText"><xsl:value-of
select="count(//Item[concat(substring(submissionDeadline,
1,4),substring(submissionDeadline, 6,2),substring(submissionDeadline,
9,2),substring(submissionDeadline,12,2),substring(submissionDeadline,15,2),s
ubstring(submissionDeadline,18,2)) > $currentDateString])"/> Ontime</p>


Thanks...

................................................................

Aaron Johnson
GUI / XSLT development
Academic Technologies Group [ATG]
University of the West of England
0117 3281051 [ext: 81051]
atg.uwe.ac.uk/aaron

SECURITY POLICY:

Please note that ATG will only accept
e-mail attachments in the following
formats: 

.asp,.bin,.doc,.gif,.html,.jpg,.mdb,.png,
.psd,.shtml,.sdf,.sit,.xls,.xml,.xsd,.xsl,.zip,

................................................................

In a wireless world without boundaries...
.who needs Gates and Windows?

................................................................

This communication is intended solely
for the use of the individual(s) to whom
it is addressed. Any opinions presented
are those of the author and do not
necessarily represent the University of
the West of England, Bristol.
................................................................



This email has been independently scanned for viruses and any virus software 
has been removed using McAfee anti-virus software

--~------------------------------------------------------------------
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>
--~--




--~------------------------------------------------------------------
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>
--~--




--~------------------------------------------------------------------
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>
--~--

<Prev in Thread] Current Thread [Next in Thread>