RE: [xsl] Writing a stylesheet to create a stylesheet, with XSLT in the XML

Subject: RE: [xsl] Writing a stylesheet to create a stylesheet, with XSLT in the XML
From: "Andrew Welch" <awelch@xxxxxxxxxxxxxxx>
Date: Tue, 18 Jun 2002 14:04:06 +0100
Scott wrote:

>Wrong.  I have been using namespace aliases just fine for a long time.
>Namespace aliases are definitely the way to go for simply creating a
>stylesheet from a stylesheet.

...right, please keep reading (no need to be so abrupt, either)

>P.S. In case anyone's wondering, my solution involves a recursive
string
>parsing template.  Anything between two | characters is taken as a
XPath
>expression.  Anything else is static text.  So, the following string
"My
>name is |/Doc/FirstName|.", would translate into the output stylesheet
as:
>
>My name is <xsl:value-of select="/Doc/FirstName"/>.

...So you do have control over the source xml?  Well in that case......

Firstly, why use | when you can use xml??

"My name is |/Doc/FirstName|." should become:

"My name is <path>/Doc/FirstName</path>."

And then you could use namespace-alias and the-power-of-xml to get the
result you want:

For this xml:

<root>
  <node>My name is <path>/Doc/FirstName</path>.</node>
</root>

And this stylesheet:

<xsl:stylesheet
	xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
	xmlns:xslt="some_made_up_namespace"
	version="1.0">
	
<xsl:namespace-alias
  	stylesheet-prefix="xslt"
  	result-prefix="xsl"/>
	
<xsl:template match="//node">
  <xsl:variable name="path" select="path"/>
  <xslt:stylesheet>
    <xslt:value-of select="{$path}"/>
  </xslt:stylesheet>
</xsl:template>

</xsl:stylesheet>


You get this result:

<?xml version="1.0" encoding="UTF-16"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
	<xsl:value-of select="/Doc/FirstName" />
</xsl:stylesheet>


Im sure this is what you need, but I dont want to second guess your reqs
- let us know if this is what you want.

cheers
andrew


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.350 / Virus Database: 196 - Release Date: 17/04/2002
 

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread