Possible to use embedded stylesheet in Transformation Scenario?

Here should go questions about transforming XML with XSLT and FOP.
RBVanDyke
Posts: 37
Location: San Francisco, California USA

Possible to use embedded stylesheet in Transformation Scenario?

Mon Feb 08, 2016 8:27 pm

------
This is a "just curious" question inspired by a textbook example, not a real work problem.

The book provides the following XML as an illustration of an embedded stylesheet, id="petstyle":

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xml" href="#petstyle"?>
<!DOCTYPE pets [<!ATTLIST xsl:stylesheet id ID #IMPLIED>]>

<pets>
  <pet type="cat">Max</pet>
  <pet type="parrot">Peter <color>red</color>
  </pet>

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

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

    <xsl:template match="pets"> My pets: <xsl:apply-templates/>
    </xsl:template>

    <xsl:template match="pet">
      <xsl:value-of select="text()"/>
    </xsl:template>

  </xsl:stylesheet>
</pets>

Is it possible to configure an oXygen 17 Transformation Scenario to use this?

As I said, I'm merely curious. I only today learned how to configure a Transformation Scenario to use a linked stylesheet. Now I'm figuring out how to use an embedded stylesheet should the need arise (highly improbable it ever will, I think)...

Cheers & thanks,
Riley
SFO
adrian
Posts: 2391

Re: Possible to use embedded stylesheet in Transformation Scenario?

Tue Feb 09, 2016 11:47 am

Hi,

RBVanDyke wrote:Is it possible to configure an oXygen 17 Transformation Scenario to use this?

Possible, yes. But not in a comfortable way.
Xalan (XSLT 1.0) seems to accept embedded XSL, but Oxygen won't recognize the anchor in the href from the xml-stylesheet declaration, so you can't make use of the Use "xml-stylesheet" declaration option. You can create a scenario (XML transformation with XSLT), select Xalan from the Transformer combo and use in the XSL URL field:

Code: Select all

${currentFileURL}#petstyle

TBH, it makes more sense to go the other way and just include the XML content within the XSL.

Regards,
Adrian
Adrian Buza
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
RBVanDyke
Posts: 37
Location: San Francisco, California USA

Re: Possible to use embedded stylesheet in Transformation Scenario?

Tue Feb 09, 2016 8:53 pm

Thanks Adrian for taking the time to respond with that excellent answer!

Cheers,
Riley
SFO

Return to “XSLT and FOP”

Who is online

Users browsing this forum: No registered users and 1 guest