Re: [xsl] xsl:processing-instruction

Subject: Re: [xsl] xsl:processing-instruction
From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx>
Date: Mon, 14 Oct 2002 15:46:17 +0100
Hi Dave,

> I need to generate
> <?xml-stylesheet href="base.css" type="text/css"?>
> except that the href needs to come from an xhtml file
> I have
>   <xsl:if test="html:html/html:head/html:link[@rel='stylesheet']">
>         <xsl:processing-instruction name="xml-stylesheet">
>           href="<xsl:value-of
> select="html:html/html:head/html:link[@rel='stylesheet']/@href"/>"
>           type="text/css"
>         </xsl:processing-instruction>
>       </xsl:if>

That looks fine. Doesn't it work?

> Is this a bit like putting markup into xsl:comment, a nono?

The same rules apply for the content of xsl:processing-instruction as
do for xsl:comment, yes -- you can't create nodes aside from text
nodes within them. But that's all you're doing in the above --
creating text -- so what you have should be fine. If you tried to do:

  <xsl:processing-instruction name="xml-stylesheet">
    <xsl:attribute name="href">
      <xsl:value-of select="html:html/html:head/html:link[@rel='stylesheet']/@href"/>
    <xsl:attribute name="type">text/css</xsl:attribute>

*that* would be an error.



Jeni Tennison

 XSL-List info and archive:

Current Thread