[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: problem getting "every" expression to work
Hi Joyce,
At 01:47 PM 7/20/2009, you wrote: Beginner here! I've been trying to use the "every" expression, but I can't seem to get it right. I put an example below and I'm hoping someone can help. I'm trying to do one thing when the element <container> is encoded for every c02[not(@level)] but something else when some of the c02[not(@level)] do not have <container> encoded. The example XSL code below is currently processing both of the <c01> in the example XML, even though the second <c01> has a <c02> with no <container> encoded. It seems to me this could be rephrased from "do X when every c02[not(@level)] has a did/container, and Y when not" to "do Y when some c02[not(@level)] has a did with no container, and X when not". Arguably, this would also be more straightforward, since you could simply test for the existence of a c02/did[not(container)], and not worry about the "every" test. So: <xsl:template match="c01[@level='series']"> ... process c01 elements when every c02/did has a container ... </xsl:template> <xsl:template match="c01[@level='series'][c02[not(@level)]/did[not(container)]" priority="2"> ... override the other template when a c02 exists with a did w/o a container ... </xsl:template> Note that this only holds together if c02 always has 'did' (which IIRC will be true in valid EAD). Also I'm taking your word for it that the absence of @level on the c02 really matters (i.e. that some c02 have @level and others don't, and this difference makes a difference). Good luck, Wendell XSL: <xsl:template c01[@level='series']> <xsl:when test="c02[not(@level)][every $i in did satisfies $i/container]"> ...do such and such... ...otherwise do such and such... </xsl:template> ====================================================================== 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 ======================================================================
|
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
|