This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
REQUIRED vs. IMPLIED attributes
- To: xsl-list at mulberrytech dot com
- Subject: REQUIRED vs. IMPLIED attributes
- From: bryan dot s dot schnabel at exgate dot tek dot com
- Date: Fri, 21 Jul 2000 13:36:52 -0700
- Reply-To: xsl-list at mulberrytech dot com
If my DTD defines an element with some REQUIRED and some IMPLIED attributes:
<!ELEMENT Link (#PCDATA) >
<!ATTLIST Link
linkid CDATA #REQUIRED
date CDATA #IMPLIED >
And I have an instance that SOMETIMES uses the implied attribute:
...some text<Link linkid="d4545" date="19JUL00">some text</Link>
some textsome text some text <Link linkid="d4546">some text</Link> some
text. . .
And I want to capture all possible combinations and deal with them:
<xsl:template match="Link">
<h2>
<xsl:attribute name="name">
<xsl:value-of select="./@linkid"/>
</xsl:attribute>
<xsl:attribute name="date">
<xsl:value-of select="./@date"/>
</xsl:attribute>
<xsl:apply-templates/>
</h2>
</xsl:template>
The result is CLOSE, but not exactly correct
...some text<h2 name="d4545" date="19JUL00">some text</h2>
some text some text <h2 name="d4546" date="">some text</h2> some text. . .
(date="" is the undesired output)
Is there a better way?
(such as perhaps) Is there a generic way to code for
1. "grab any attribute and simply repeat it"
or
2. "grab IMPLIED attribute WHEN they're there
and deal with them"
Thanks,
Bryan Schnabel
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list