Possible to use embedded stylesheet in Transformation Scenario?

Here should go questions about transforming XML with XSLT and FOP.
RBVanDyke
Posts: 88
Joined: Wed Feb 11, 2015 11:25 pm
Location: San Francisco, California USA
Contact:

Possible to use embedded stylesheet in Transformation Scenario?

Post by RBVanDyke »

------
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: 2855
Joined: Tue May 17, 2005 4:01 pm

Re: Possible to use embedded stylesheet in Transformation Scenario?

Post by adrian »

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: 88
Joined: Wed Feb 11, 2015 11:25 pm
Location: San Francisco, California USA
Contact:

Re: Possible to use embedded stylesheet in Transformation Scenario?

Post by RBVanDyke »

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

Cheers,
Riley
SFO
Post Reply