? If I post this request to the page: http://www.server.com/show.xml?color=red&n...">

Is there something like <xsl: url-param name = "color" / ">?

If I post this request to the page:

http://www.server.com/show.xml?color=red&number=two

      

Can I do something like this?

I like the color <xsl:url-param name="color" /> and the number <xsl:url-param name="number" />.

      


If you need to clarify a question, lemme know

Thanks for any answers,

Chrelad

0


source to share


1 answer


Not; in general, XSL engines are not tied to the web server.

However, most XSL engines allow you to pass some parameters along with your stylesheet and document, so you can do this if you call it from a system with a web interface, map your GET parameters directly to your XSL interface engine.

For example, if you are using PHP, you can do something like this:



<?php

$params = array(
    'color' => $_GET['color'],
    'number' => $_GET['number']
);

$xsl = new DOMDocument;
$xsl->load('mystylesheet.xsl');

$xml = new DOMDocument;
$xml->load('mydocument.xml');

$proc = new XSLTProcessor;
$proc->importStyleSheet($xsl); // attach the xsl rules

foreach ($params as $key => $val)
    $proc->setParameter('', $key, $val);

echo $proc->transformToXML($xml);

      

You will need to make sure you sanitize whatever you went through. Then you can simply:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet 
  version="1.0" 
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <!-- Remember to pick-up the parameters from the engine -->
  <xsl:param name="color" />
  <xsl:param name="number" />
  <xsl:template match="*">
    I like the color <xsl:value-of select="$color" /> 
    and the number <xsl:value-of select="$number" />.
  </xsl:template>
</xsl:stylesheet>

      

+1


source







All Articles