Page 1 of 1

Possible to use embedded stylesheet in Transformation Scenario?

Posted: Mon Feb 08, 2016 8:27 pm
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

Re: Possible to use embedded stylesheet in Transformation Scenario?

Posted: Tue Feb 09, 2016 11:47 am
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

Re: Possible to use embedded stylesheet in Transformation Scenario?

Posted: Tue Feb 09, 2016 8:53 pm
by RBVanDyke
Thanks Adrian for taking the time to respond with that excellent answer!

Cheers,
Riley
SFO