|
[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
[Recent Entries]
[Reply To This Message]
RE: container list display problem
Subject: RE: container list display problem
From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx>
Date: Mon, 06 May 2002 18:25:37 -0400
|
Loren:
Assuming you are matching on a did element, this test should generalize to
work both at the level of the c02 and of the c03:
<xsl:when
test="(../preceding-sibling::*[1]/did/container[@type='reel']=$reelnumber)
or
(../parent::*/did/container[@type='reel']=$reelnumber)">
Notice that this doesn't constrain the preceding sibling of the parent (of
the did context node) to be either a c03 or a c02; it just checks its
preceding sibling (a c03 if this did is in a c03, or nothing at all for the
first one; or a c02 if this did is in a c02) and that of its parent (a c02
if this is a c03, otherwise ... something that depends on your source).
Is this what you want? Matching on the did element (which I've assumed,
from your code, is what you're doing) allows you a nice generalized
approach. But matching on the c02 and c03 elements separately and then
reaching down into their respective did elements with your XPath, might
provide for more clarity in your code, if not quite so much compression.
Does that help?
Cheers,
Wendell
At 03:21 PM 5/6/2002, you wrote:
Hi folks,
Here I go again...
I have included my XSL and XML code if it will help anyone to figure out
how I can make this work.
Basically I am having problems with the second line of the test, the code
after the *or*. If I replace ../parent with preceding then reel number
5248 frame 485-589 is displayed as if it was the same reel as the previous
one, 5249.
thanks for any help you can offer me,
Loren
XSL code
¯-----------------------------------------------------
<!--Creates a variable for testing container values.-->
<xsl:variable name="reelnumber">
<xsl:value-of select="container[@type='reel']"/>
</xsl:variable>
<xsl:choose>
<xsl:when
test="(../preceding-sibling::c03[1]/did/container[@type='reel']=$reelnumber)
or
(../parent::c02/did/container[@type='reel']=$reelnumber)">
<!--Selects cases where the value of the reel
container is the same as that of a previous
component. In that case, no column labels are
added and only the frame number appears
along with the other component data.-->
<tr>
<td> </td>
<td valign="top">
<xsl:value-of
select="container[@type='frame']"/>
</td>
<td> </td>
<td colspan="7" align="left"
valign="top">
<xsl:apply-templates
select="unitid"/>
<xsl:text> </xsl:text>
<xsl:call-template
name="unittitle-stuff"/>
<xsl:text> </xsl:text>
<xsl:apply-templates
select="physdesc"/>
<xsl:text> </xsl:text>
<xsl:apply-templates
select="abstract"/>
</td>
</tr>
</xsl:when>
<!--Selects cases where the value of the reel
container is not the same as that of a previous
component. In that case, column labels are
added and both the reel and frame number appears
along with the other component data.-->
<xsl:otherwise>
<tr>
<td><br /><b>Reel</b></td>
<td><br /><b>Frame</b></td>
</tr>
<tr>
<td valign="top">
<xsl:value-of
select="container[@type='reel']"/>
</td>
<td valign="top">
<xsl:value-of
select="container[@type='frame']"/>
</td>
<td> </td>
<td colspan="8" align="left"
valign="top">
<xsl:apply-templates
select="unitid"/>
<xsl:text> </xsl:text>
<xsl:call-template
name="unittitle-stuff"/>
<xsl:text> </xsl:text>
<xsl:apply-templates
select="physdesc"/>
<xsl:text> </xsl:text>
<xsl:apply-templates
select="abstract"/>
</td>
</tr>
</xsl:otherwise>
</xsl:choose>
XML code
¯-------------------------------------------------------
<c02>
<did>
<container type="reel">5248</container>
<container type="frame">22</container>
<unittitle>1st test c02, reel number is 5248
</unittitle>
</did>
</c02>
<c02>
<did>
<container type="reel">5248</container>
<container type="frame">23</container>
<unittitle>same as previous c02, reel number is 5248
</unittitle>
</did>
<c03>
<did>
<container type="reel">5248</container>
<container type="frame">1466-1467</container>
<unittitle>1st test c03, reel number is same as above (5248)
</unittitle>
</did>
</c03>
<c03>
<did>
<container type="reel">5249</container>
<container type="frame">321</container>
<unittitle>c03 level, reel number changes to 5249
</unittitle>
</did>
</c03>
<c03>
<did>
<container type="reel">5249</container>
<container type="frame">322</container>
<unittitle>c03 level and reel number same as above (5249)
</unittitle>
</did>
</c03>
<c03>
<did>
<container type="reel">5248</container>
<container type="frame">485-589</container>
<unittitle>c03 level, reel number changes back to 5248
</unittitle>
</did>
</c03>
<c03>
<did>
<container type="reel">5248</container>
<container type="frame">785</container>
<unittitle>c03 level, same reel number as as above (5248)
</unittitle>
</did>
</c03>
</c02>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>The basic problem of your tests using preceding-sibling:: might be
alleviated by shifting to the preceding:: axis. While I know EAD, like Mike
I can't see deeply into your problem without seeing an example of source
code. (As you know there are many ways to do EAD.)
You can test whether the parent of the <did> that houses the <container>
has the same number by going up *two* levels -- "../../@n = @n".
But it sounds like since the tracking of the microfilm reels has no
relation to the XML structure of the source, the preceding:: axis may be a
winner. If you want to check ancestors as well as preceding elements (you
may), check both preceding:: and ancestor:: axes.
Also, problems like yours are often made considerably easier with a
two-pass solution. This is especially the case if there's any sorting
involved (but it sounds like your stuff is already sorted). Even if this
isn't so for you, checking preceding:: can get expensive of processing
cycles (the axis goes all the way back to the start of the document), and
this can be alleviated by running two passes.
For more explicit help, please post a sample of your source (trimmed for
clarity) with the applicable bit of stylesheet.
Regards,
Wendell
At 05:42 PM 5/1/2002, you wrote:
>Michael,
>I am sure I'm doing this wrong as I am a newbie at coding XSL. I am trying
>to find if the parent of the container / the parent of the <did> that
>houses the <container> tag / also has the same container number. So if the
>subseries ends and another series starts, but they are both microfilmed on
>the same reel, then the reel number is not repeated.
>How do I test that in XSL? I tried your suggestion, but unfortunately it
>doesn't solve the problem.
>Thanks very much for responding so quickly. I am really amazed at the
>generosity of people on this list to help even newbies like me.
>Loren
>
>/------------------------------------------------------------
>Date: Wed, 1 May 2002 15:01:55 +0100
>From: "Michael Kay" <michael.h.kay@xxxxxxxxxxxx>
>Subject: RE: container list display problem
>
> > I have been using a style sheet that supports an XML DTD
> > called EAD - Encoded Archival Description. ....
> >aeel">5248</container>
<container
> > <xsl:when test="(../preceding-sibling::c03[1]//did/container
> > @type='reel']=$reelnumber
> > or parent::c02[last()]/did/container[@type='reel']=$reelnumber)">
> >
>I haven't tried to understand your detailed logic but the
>parent::c02[last()] test looks wrong. A node has exactly one parent so the
>predicate [last()] is always true. You obviously don't want to select the
>"last parent" because there is only one. Perhaps you want to test whether
>the parent is the last child of its own parent? In that case the condition
>would be parent[not(following-sibling::*)].
======================================================================
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
======================================================================
Loren Scherbak
Archives of American Art
Smithsonian Institution
202-275-1687
scherbakl@xxxxxx
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
======================================================================
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

|
PURCHASE STYLUS STUDIO ONLINE TODAY!
Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!
Download The World's Best XML IDE!
Accelerate XML development with our award-winning XML IDE - Download a free trial today!
Subscribe in XML format
| RSS 2.0 |
|
| Atom 0.3 |
|
|