xsl-list
[Top] [All Lists]

RE: [xsl] question on xml-stylesheet processing instruction for browsers

2009-05-19 09:32:03
Hermann,

It looks like you're trying to perform another XSL transform on the result of a 
XSL transform, but you're trying to leverage against the browser to do it. It 
won't work; the document you output from the built-in transform will only be 
seen as an XML document, where a <?xml-stylesheet?> processing instruction is 
just a processing instruction node. It won't trigger another transform.

It looks like you'll instead want to capture your output into a temporary tree, 
and use the built-in node-set() extension function to run the second transform 
instead. If you can modify x.xsl and y.xsl here so they can work separately (no 
clash of template rules), you'll be best off.

For example, in y.xsl (with <?xml-stylesheet type="text/css" href="y.xsl" ?> at 
the top of your XML source):

<xsl:stylesheet version="1.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
  xmlns:exsl="http://exslt.org/common";
  xmlns:msxsl="urn:schemas-microsoft-com:xslt"
  exclude-result-prefixes="exsl msxsl">
  <xsl:output method="html" encoding="UTF-8" />
  <xsl:import href="x.xsl" />
  <xsl:template match="/">
    <xsl:variable name="first-pass">
      <xsl:apply-imports />
    </xsl:variable>
    <xsl:choose>
      <xsl:when test="function-available(exsl:node-set)">
        <xsl:apply-templates select="exsl:node-set($first-pass)" />
      </xsl:when>
      <xsl:when test="function-available(msxsl:node-set)">
        <xsl:apply-templates select="msxsl:node-set($first-pass)" />
      </xsl:when>
    </xsl:choose>
  </xsl:template>
</xsl:stylesheet>

I hope that's clear enough.

Scott

-----Original Message-----
From: Michael Dykman [mailto:mdykman(_at_)gmail(_dot_)com] 
Sent: Tuesday, May 19, 2009 7:15 AM
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: Re: [xsl] question on xml-stylesheet processing instruction for 
browsers

Your stylesheet is lacking an output tag which contains key meta-data
for the tranform


<?xml version="1.0" encoding="ISO-8859-1"?>

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>

<xsl:output encoding="UTF-8" indent="no" media-type="text/html" method="html" />

<xsl:template ...>
....

I am not sure what you are doing within the stylesheet..  there
certainly is no need to match the processing instruction,; that will
be handled auto-magically..  The first template need only look like so
to match the document  root:

<xsl:template match="/">
...

but I have no idea what yu or trying to achieve here, so I don't know
where it goes from there


On Tue, May 19, 2009 at 6:17 AM, Hermann Stamm-Wilbrandt
<STAMMW(_at_)de(_dot_)ibm(_dot_)com> wrote:

Hello,

is it possible to chain execution of stylesheets if opening eg.
"http://..../x.xml"; in a web browser?

By the pieces below "x.xml" will execute stylesheet "x.xsl" in the browser
and replace the processing
instruction's 'href="x.xsl" ' by 'href="y.xsl" ' in the generated output.

What appears in the browser is the output of execution of stylesheet
"x.xsl" only, no execution of "y.xsl".
If chaining stylesheet execution is possible, what is missing?


$ cat x.xml
<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet type="text/xsl" href="x.xsl"?>
...

$ cat x.xsl
<?xml version="1.0" encoding="ISO-8859-1"?>

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>

<xsl:template match="/processing-instruction('xml-stylesheet')">
 <xsl:processing-instruction name="xml-stylesheet">
   <xsl:value-of select="substring-before(.,'href=')"/>
href="y.xsl"</xsl:processing-instruction>
</xsl:template>
...


Mit besten Grüßen / Best wishes,

Hermann Stamm-Wilbrandt
Developer, XML Compiler
WebSphere DataPower SOA Appliances
----------------------------------------------------------------------
IBM Deutschland Research & Development GmbH
Vorsitzender des Aufsichtsrats: Martin Jetter
Geschäftsführung: Erich Baier
Sitz der Gesellschaft: Böblingen
Registergericht: Amtsgericht Stuttgart, HRB 243294


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: 
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--





-- 
 - michael dykman
 - mdykman(_at_)gmail(_dot_)com

 - All models are wrong.  Some models are useful.

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>