I'm trying to process an XML document for which certain elements may or may
not exist.
How can I handle this?
E.g.
<xsl:if test= "element exists"></xsl:if>
<xsl:if test= "element does not exist"></xsl:if>
Partial XML document:
<PropertyGroup name="WorkItem"
class="com.ibm.xml.parsers.performance.workitems.Xerces2DOMCount"><property
name="d" displayname="Defer Node Expansion" value="true" /><property name="f"
displayname="Schema Full Support" value="false" /><property name="gpn"
displayname="Grammar Pool Name"
value="org.apache.xerces.util.XMLGrammarPoolImpl" />displayname="Grammar
Caching" value="true" />displayname="Load External DTD" value="true"
/>displayname="Memory Read" value="true" />displayname="Namespaces"
value="true" />displayname="Schema Support" value="false" />displayname="Set
SystemID" value="true" />displayname="Traverse DOM" value="true"
/>displayname="URI" value="doc.xml" />displayname="Validation" value="true"
/>These elements aren't always present, and when they are not I need to do
something
<property name="d" displayname="Defer Node Expansion" value="true" />
<property name="tr" displayname="Traverse DOM" value="true" />
Partial XSL document:
I have tried:
This gives me no output:
<xsl:when test="@displayname != string('Traverse DOM') and
string-length(normalize-space(@displayname)) = 0"><xsl:text>n/a</xsl:text>
The ones below gives me output for each property /displayname, but I only
need it to print for one occasion:
<xsl:when test="@displayname != string('Traverse DOM')
"><xsl:text>n/a</xsl:text>
<xsl:when test="@displayname != string('Traverse DOM') and
string-length(normalize-space(property/@displayname)) =
0"><xsl:text>n/a</xsl:text>
</xsl:when>
Any help you can provide would be appreciated.
Thanks, Tanya
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list