> Should parent:: be replaced with another relationship here?
Yes, exactly. The parent of X is the element immediately above X in
the document tree (not in linear order). Per your example, then, the
parent of arrangement and scopecontent is the <c01>; the parent of
unittitle and physdesc is the <did>; the parent of unitdate is the
<unittitle>. Maybe this formatting will make it clearer:
<c01 level="series">
<did>
<unittitle>
<unitdate></unitdate>
</unittitle>
<physdesc></physdesc>
</did>
<arrangement></arrangement>
<scopecontent>
<p></p>
</scopecontent>
</c01>
So for the ones whose parent is <did>, you need to go up one more level
to the "grandparent" c0# and check that, which you can do using the
"ancestor" axis and specifying how many levels up you want to go --
ancestor[1] is the parent so:
<xsl:template match='unittitle'>
<xsl:choose>
<xsl:when test='ancestor::*[2][@level="series" or
@level="subseries"]'>
For the unitdate, you need to walk back up the tree 2 levels to the
c0#, so this should do it:
<xsl:template match='unitdate'>
<xsl:choose>
<xsl:when test='ancestor::*[3][@level="series" or
@level="subseries"]'>
Note that if unitdate is sometimes inside the unittitle and sometimes
not, it gets trickier because you have to check both conditions!
Michele
-=--=--=--=--=--=--=--=--=--=--=--=--=--=-
Michele R. Combs
[log in to unmask]
Manuscripts Processor
Special Collections Research Center
Syracuse University Library
222 Waverly Avenue
Syracuse, NY 13244
(315) 443-2697
-=--=--=--=--=--=--=--=--=--=--=--=--=--=-
>>> [log in to unmask] 2/8/2007 11:23 AM >>>
The below choose template worked beautifully for arrangement, note and
scopecontent. I also tried to format unittitle and physdesc in the same
way but all are getting passed to otherwise even when (I believe) they
should meet the first choose criteria. There must be a problem with this
part of the statement.
<xsl:template match='scopecontent'>
<xsl:choose>
<xsl:when test='parent::*[@level="series" or
@level="subseries"]'>
Should parent:: be replaced with another relationship here?
<dsc type="combined">
<c01 level="series"><did><unittitle><unitdate></unitdate></unittitle>
<pysdesc></physdesc></did><arrangement></arrangement>
<scopecontent><p></p></scopecontent></c01>
Thanks again,
Lynn
-----Encoded Archival Description List <[log in to unmask]> wrote: -----
To: [log in to unmask]
From: Michele Combs <[log in to unmask]>
Sent by: Encoded Archival Description List <[log in to unmask]>
Date: 02/06/2007 04:30PM
Subject: Re: Not statement?
Actually the "not (A or B)" construction does seem to work; possibly
the
boolean condition within the parenthesis -- in this case "(A or B)" --
is evaluated first, and then it applies the "not" ? In other words,
it
doesn't appear to "not" the two conditions separately, which means
that
"not(A or B)" isn't the same thing as "not(A) or not(B)." The upshot
of
it is that the "not(A orB)" construction seems to behave more like
"neither A nor B."
In any case, an easier (and prettier!) way to solve the problem might
be to use the choose/ when/otherwise construction, like so:
<xsl:template match='scopecontent'>
<xsl:choose>
<xsl:when test='parent::*[@level="series" or
@level="subseries"]'>
<p>THIS IS AN S or SS <xsl:apply-templates/> </p>
</xsl:when>
<xsl:otherwise>
<p>THIS IS NOT AN S or SS <xsl:apply-templates/> </p>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
This targets the exact element (scopecontent) that you want to format
in a distinct way and doesn't require that pesky "not" at all :)
Michele C.
-=--=--=--=--=--=--=--=--=--=--=--=--=--=-
Michele R. Combs
[log in to unmask]
Manuscripts Processor
Special Collections Research Center
Syracuse University Library
222 Waverly Avenue
Syracuse, NY 13244
(315) 443-2697
-=--=--=--=--=--=--=--=--=--=--=--=--=--=-
>>> [log in to unmask] 2/6/2007 3:29 PM >>>
Hi,
Actually this is a boolean problem...
Forgive the shorthand - this is about the logic not the actual syntax
In the first template you ask for series *or* subseries so that means
anything that isn't a series or a subseries will be excluded
In the second template you ask for not(series or subseries) which is
different than " not(series) and not(subseries)"
AN example:
Of the following items:
seriesA
seriesB
subseriesA
subseriesB
fileA
fileB
documentA
documentB
template1 would retrieve:
seriesA
seriesB
subseriesA
subseriesB
But in template2 I assume what you are trying to retrieve is
fileA
fileB
documentA
documentB
and any other items that are not a series or a subseries
But as you have written it not(series or subseries)
those that are subseries are INCLUDED when you are performing the
not()
on the series but those that are series are INCLUDED when you are
performing the not() on the subseries portion of the statement. That
is
ambiguous because of the *OR* in between.
If you write it
not(series) or not(subseries) you still face a similar problem.
If you write not(series and subseries) then you would be looking for
those that had levels that matched both series and subseries. There
would be no matches matches. That isn't correct either.
But if you want to say that you do not want to include series and you
do
not want to include subseries in your results then you should say
"not(series) and not(subseries)" (translated into the correct xslt
syntax).
Hope that helps.
Liz
Lynn Lobash wrote:
> aha. thank you and for the website.
>
> lynn
>
>
>
>
> Michele Combs
> <[log in to unmask]
> >
To
> Sent by: Encoded [log in to unmask]
> Archival
cc
> Description List
> <[log in to unmask]>
Subject
> Re: Not statement?
>
> 02/06/2007 02:12
> PM
>
>
> Please respond to
> Encoded Archival
> Description List
> <[log in to unmask]>
>
>
>
>
>
>
> I think possibly the wildcard double slash is confusing it...the
double
> slash tells it to find scopecontent anywhere in the document; even
when
> you put it in the middle of a string as you have it here, it's still
an
> anywhere-in-the-document match (see "Navigating nodes" at
> http://builder.com.com/5100-6371-1044797-2.html ). If you take out
> the double slash, it works fine. Given that a scopecontent can only
> appear in a c0# or in another scopecontent, you may not need that
double
> slash.
>
> Michele
>
> -=--=--=--=--=--=--=--=--=--=--=--=--=--=-
> Michele R. Combs
> [log in to unmask]
> Manuscripts Processor
> Special Collections Research Center
> Syracuse University Library
> 222 Waverly Avenue
> Syracuse, NY 13244
> (315) 443-2697
> -=--=--=--=--=--=--=--=--=--=--=--=--=--=-
>
>>>> [log in to unmask] 2/6/2007 1:01 PM >>>
> I keep getting an ambiguous rule match error here and I am not
> understanding how these two statements are not opposites:
>
> <xsl:template match='* [@level="series" or
> @level="subseries"]//scopecontent'>
>
> <p>
> <xsl:apply-templates/>
> </p>
> </xsl:template>
>
> <xsl:template match='* [not (@level="series" or
> @level="subseries")]//scopecontent'>
>
> <font size="-1" color="gray">
> <xsl:apply-templates/>
> </font>
> </xsl:template>
>
> Thank you,
> Lynn
>
|