This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: How do you get Attributes in Processing Instructions using IE6
- From: Jeni Tennison <jeni at jenitennison dot com>
- To: "Bolen, Lori Contractor/WESTAR CORPORATION" <Lori dot Bolen at redstone dot army dot mil>
- Cc: XSL-List at lists dot mulberrytech dot com
- Date: Tue, 30 Apr 2002 16:55:31 +0100
- Subject: Re: [xsl] How do you get Attributes in Processing Instructions using IE6
- Organization: Jeni Tennison Consulting Ltd
- References: <402D2E759AFCD3119C7600805F6FE93206E691F6@ex-immc01.redstone.army.mil>
- Reply-to: xsl-list at lists dot mulberrytech dot com
Hi Lori,
> I have the following processing instructions throughout my xml file:
> <?FRAME LABEL='Introduction to IADS' SHOWNO='N'?>
>
> I need to be able to get the value of the LABEL attribute
> (Introduction to IADS). I am using IE 6.0. I can match the
> processing instruction, but I can't seem to get the individual
> attribute values. I have tried <xsl:value-of select="@label"/>, but
> this doesn't seem to work.
The "attributes" in processing instructions aren't actually attributes
-- they just look like them. Noramally people refer to these kinds of
"attributes" as "pseudo-attributes" to emphasise that fact. As far as
the XPath data model is concerned, the only information you can get
about a processing instruction is its target (or name -- 'FRAME' in
this case), its value ("LABEL='Introduction to IADS' SHOWNO='N'") and
its location in the node tree.
Pulling the pseudo-attributes out of the processing instruction, then,
involves the same kind of code as you'd use to parse any structured
string. To get the value of the LABEL pseudo-attribute, for example,
you could use:
<xsl:template match="pi('FRAME')">
<A name='{substring-before(
substring-after(., "LABEL='"), "'")}">
<xsl:value-of select="." />
</A>
</xsl:template>
(This assumes that you're using apostrophes rather than double-quotes
around the values of the pseudo-attribute.)
Cheers,
Jeni
---
Jeni Tennison
http://www.jenitennison.com/
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list