use xsl:element to output an "<xsl:template match=...> ?

R

Ray Tayek

hi, trying to use an xslt to make an xslt. trying something like:

<?xml version="1.0" encoding="UTF-8"?>
<?xmlspysamplexml H:\java\projects\spy1\spy\inputDocumentMap.xml?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:eek:utput method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:template match="/inputDocumentMap">
<xsl:element name="xsl:template" match="/inputDocument">
<xsl:apply-templates/>
</xsl:element>
</xsl:template>
</xsl:stylesheet>

but this is not going very well (the files are at:
http://tayek.com/~ray/spy1/

i want to create the sampleT1.xslt file (which will eat
inputDocument.xml) from inputDocumentMap.xml. the sampleT1 works fine
(at least in java, but xmlspy produces garbage). i want to create this
file programmatically.

i would assume that this (creating an xslt from an xslt and an xml)
*can* be done but maybe it would be better to do it in java as i am a
newbie to xslt (it's my first functional langauge). i have done this
with a previous incarnation of the sampleT1.xslt, so it's not a problem,
but it would be cool to do it in xslt.

any pointers would be apreciated.

thanks
 
R

Ray Tayek

Ray said:
hi, trying to use an xslt to make an xslt. trying something like:

...
<xsl:template match="/inputDocumentMap">
<xsl:element name="xsl:template" match="/inputDocument">
<xsl:apply-templates/>
</xsl:element>
</xsl:template>

this may be working a bit better:

<?xml version="1.0" encoding="UTF-8"?>
<?xmlspysamplexml H:\java\projects\spy1\spy\inputDocumentMap.xml?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:eek:utput method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:template match="/inputDocumentMap">
<xsl:element name="xsl:template">
<xsl:attribute name="match">/inputDocumentt</xsl:attribute>
<!--xsl:attribute name="xml:space">preserve</xsl:attribute>-->
<xsl:apply-templates/>
</xsl:element>
</xsl:template>
</xsl:stylesheet>
 
D

Dimitre Novatchev

Read also about the
xsl:namespace-alias
instruction.

Using it to produce an xsl:stylesheet as the result of the transformation is
more convenient than using xsl:element.

Of course, it is also recommended to try another solution that solves your
problem directly, without having to produce an intermediate stylesheet.

=====
Cheers,

Dimitre Novatchev.
http://fxsl.sourceforge.net/ -- the home of FXSL
 
R

Ray Tayek

Dimitre said:
Read also about the xsl:namespace-alias instruction.
ok

Using it to produce an xsl:stylesheet as the result of the transformation is
more convenient than using xsl:element.

Of course, it is also recommended to try another solution that solves your
problem directly, without having to produce an intermediate stylesheet.

that is a great idea, but i ahev no clue how to do it.

i have a sample of the desired type of xslt that i want to produce
called sampleT1.xsl at http://tayek.com/~ray/spy1/. it transforms the
inputDocument.xml into what is needed. (the problem is to consume .csv's
from excel that have notes with line breaks and ' and " and space
charaters in the field names, so i have a csvparser that makes
inputDocument.xml from the lusers' .csv).

another input is the inputDocumentMap.xml which describes the processing
that needs to be done on the inputDocument.xml file (this involves
renaming fields, deleting fields, mapping data values of fields, and
outputting records based on trigger fields in the input records).

the idea is to let the user define the processing to be done on his csv
file to get it into our xml/csv format, so this is done by a web app and
i will get an inputDocumentMap.xml from this user interaction and then
he can upload his .csv's so we can process them and stick 'em in our system.

thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,734
Messages
2,569,441
Members
44,832
Latest member
GlennSmall

Latest Threads

Top