function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
tggagnetggagne 

Trying to create XSLT: Save error: Component /apexcomponent/xsl__stylesheet does not exist

I need to generate both an XML doc and XSLT from inside VF.  

 

I can create an XML easily eough, but I'm having trouble with the XSLT.

 

I've stripped-down the XSLT to its bare essentials.

<apex:page contentType="text/xml" showHeader="false" sidebar="false" expires="1">
  <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

  </xsl:stylesheet>
</apex:page>

 

 

When I try saving it, I get, "Save error: Component /apexcomponent/xsl__stylesheet does not exist."

 

Does anyone know if such a thing can be done, or why the code above won't save?

Best Answer chosen by Admin (Salesforce Developers) 
tggagnetggagne

Somewhat satisfactory work-around.

 

I created a component as:

 

<apex:component controller="AquariusXMLController">{!xmlpi}
{!stylesheetReference}
<apex:componentBody />
</apex:component>

 

The controller provides the two merge fields which as you might expect expand to:

 

<?xml version="1.0"?> and <?xml-stylesheet type="text/xsl" href="AquariusXSLT" ?> respectively.

 

The XSLT file resembles:

 

<apex:page contentType="text/xml" showHeader="false" sidebar="false" cache="true">
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template>.....</xsl:template>
</xsl:stylesheet>
</apex:page>

 

The version attributes above are important.  Firefox and Opera mobile crashed without them.  xsltproc was useful in finding this.

All Answers

calvin_nrcalvin_nr

Why do you need a XSLT stylesheet within the apex page? if you need it for some kind of transformation, cant you save it as an external resource and refer to it in your page?

tggagnetggagne

I could, but I'd rather have it exist as a page so I might auto-generate some of its content and be able to edit it inside Develop->Pages than have to load zip files.

tggagnetggagne

Somewhat satisfactory work-around.

 

I created a component as:

 

<apex:component controller="AquariusXMLController">{!xmlpi}
{!stylesheetReference}
<apex:componentBody />
</apex:component>

 

The controller provides the two merge fields which as you might expect expand to:

 

<?xml version="1.0"?> and <?xml-stylesheet type="text/xsl" href="AquariusXSLT" ?> respectively.

 

The XSLT file resembles:

 

<apex:page contentType="text/xml" showHeader="false" sidebar="false" cache="true">
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template>.....</xsl:template>
</xsl:stylesheet>
</apex:page>

 

The version attributes above are important.  Firefox and Opera mobile crashed without them.  xsltproc was useful in finding this.

This was selected as the best answer