xsl-list
[Top] [All Lists]

Re: [xsl] How to produce X when an attribute of an element does not exist or equals Y?

2008-07-08 19:58:05
I think the xpath expression your looking for would be:

data-field[(_at_)tag='555'][not(exists(@ind1))]

-- Jeff

On 07 9, 08, at 10:46 AM, Joyce Celeste Chapman wrote:

Hi, I'm new to the listserv and to XSL. Using the XML below and XSLT 1.0, I would like content to appear both when an attribute of an element does not exist and when it equals X. Specifically, I would like the contents of data-field tag 555 to appear if this data-field does not have any "ind1" attribute, or if its ind1 equals 8.

Data fields with indicators versus no indicators in my XML look like this:
<data-field tag="555" ind1="0">
   <subfield code="a">...</subfield>
</data-field>
<data-field tag="555">
   <subfield code="a">...</subfield>
</data-field>

This is the XSLT I have figured out, minus the missing part:
<xsl:if test="data-field[(_at_)tag='555'][(_at_)ind1='8'] | ...or if a data- field with attribute 555 has no attribute ind1">
   <otherfindaid encodinganalog="555">
<xsl:for-each select="data-field[(_at_)tag='555'][(_at_)ind1='8'] | ...or if a data-field with attribute 555 has no attribute ind1">
           <p>
               <xsl:value-of select="."/>
           </p>
       </xsl:for-each>
   </otherfindaid>
</xsl:if>

I would be very grateful for any help. Thank you!

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


Jeferson L. Sese
jeferson dot sese at asiatype dot com
Asiatype Inc.
Suite 114 Columbia Tower
Ortigas Ave., Greenhills
Mandaluyong City 1550 Philippines
Tel: +632-744-6262
Mobile: +63927-671-7901




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