Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

insert <?xml-stylesheet tag with xsl

Tags:

xml

xslt

How can I add stylesheet reference with XSLT?

I'm trying to strip down some large input XML with the first transform, and need the second transform to be applied on the client. Thus the first transform has to output the correct reference, e.g.:

<?xml-stylesheet type="text/xsl" href="client.xsl"?>

To recap it's XML->transform1(server)->XML->transform2(client)->HTML

The only way I can make it to work so far is by using xsl:text disable-output-escaping and CDATA:

<xsl:text disable-output-escaping="yes"><![CDATA[<?xml-stylesheet type="text/xsl" href="/efo/efo_class.xsl"?>]]>

Surely there must be a better method.

like image 796
Tomasz Avatar asked Aug 19 '09 15:08

Tomasz


People also ask

How do I create a stylesheet in XML?

Basic steps in defining a CSS style sheet for XML :Define the style rules for the text elements such as font-size, color, font-weight, etc. Define each element either as a block, inline or list element, using the display property of CSS. Identify the titles and bold them.

Can we convert XML to XSL?

The standard way to transform XML data into other formats is by Extensible Stylesheet Language Transformations (XSLT). You can use the built-in XSLTRANSFORM function to convert XML documents into HTML, plain text, or different XML schemas. XSLT uses stylesheets to convert XML into other data formats.


1 Answers

Based on the XSLT spec, Creating Processing Instructions:

<xsl:processing-instruction name="xml-stylesheet">
  <xsl:text>type="text/xsl" href="client.xsl"</xsl:text>
</xsl:processing-instruction>

would create the processing instruction:

<?xml-stylesheet type="text/xsl" href="client.xsl"?>
like image 186
legoscia Avatar answered Oct 15 '22 12:10

legoscia