Subject: Re: [xsl] Writing conditional statement based on attribute From: Kamal Bhatt <kbhatt@xxxxxxxxx> Date: Wed, 07 Feb 2007 08:36:01 +1100 |
sure, sorry, more complete example:Your description isn't particularly clear, so I just gave you an example where it replaces scopecontent with what you stated previously (or what I thought you wanted). In the future, you will find that if you give the input (as you have above) and the output you want produced, you will get a better response. This will hopefully be enough to help you on your way. This solution will only work if you have cXX elements, it won't work if the 'c' is a 'd'. If you are using a processor that supports regex processing (one that supports XSLT 2.0 or one that supports the exslt regex functions) you could tighten this processing with that.
<dsc type="combined">
<c01 level="series"><did><unittitle><unitdate></unitdate></unittitle><physdesc></physdesc></did> <arrangement.</arrangement><scopecontent><p></p></scopecontent>
<c02 level="subseries"><did><unittitle><unitdate></unitdate></unittitle><physdesc></physdesc></did> <arrangement.</arrangement><scopecontent><p></p></scopecontent>
<c03 level="file"><did><unittitle><unitdate></unitdate></unittitle><physdesc></physdesc></did> <arrangement.</arrangement><scopecontent><p></p></scopecontent></c03>
<c03><did><unittitle><unitdate></unitdate></unittitle><physdesc></physdesc></did> <arrangement.</arrangement><scopecontent><p></p></scopecontent></c03></c02></c01></dsc>
again, I am trying to format scopecontent one way where @level="series" or "subseries" and another where @level="file" or there is no attribute level.
thanks again, lynn
<?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="scopecontent"> <xsl:param name="with-series"/>
<xsl:choose> <xsl:when test="$with-series = 'true'"> <p><xsl:value-of select="."/></p> </xsl:when> <xsl:otherwise> <p><font size="-1" color="gray"/><xsl:value-of select="."/> </p> </xsl:otherwise> </xsl:choose> </xsl:template>
<xsl:template match="@*|node()"> <xsl:copy><xsl:apply-templates select="@*|node()"/></xsl:copy> </xsl:template>
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Writing conditional state, llobash | Thread | [xsl] Advice sought re WYSIWYG end-, Trevor Nicholls |
Re: [xsl] Newbie question on XSL tr, Abel Braaksma | Date | Re: [xsl] Newbie question on XSL tr, Florent Georges |
Month |