xsl-list
[Top] [All Lists]

Re: xsl:processing-instruction

2002-10-14 07:46:17
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[(_at_)rel='stylesheet']">

        <xsl:processing-instruction name="xml-stylesheet">
          href="<xsl:value-of
select="html:html/html:head/html:link[(_at_)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[(_at_)rel='stylesheet']/@href"/>
    </xsl:attribute>
    <xsl:attribute name="type">text/css</xsl:attribute>
  </xsl:processing-instruction>

*that* would be an error.

Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list