Tool that generates xsl:template tags from xsd?

K

KJ

I would like to know if there is a tool for download or purchase that
will generate a skeleton xslt document, inserting all the
xsl:template's matching each element specified in any given xsd.

Does anyone know of one?

Thanks,
KJ
 
S

scooterm

This sort of thing can be done relatively easily with any of the
various
scripting languages that have XML libraries (python, perl, ruby). All
of which can be downloaded and installed on every major OS out there,
usually with no license fee.
 
S

Soren Kuula

KJ said:
I would like to know if there is a tool for download or purchase that
will generate a skeleton xslt document, inserting all the
xsl:template's matching each element specified in any given xsd.

Does anyone know of one?

Thanks,
KJ
Tell me more about what you want to use it for please.

I am writing a collection of schema-aware tools for XSL right now. I
might want to include that if it's really practically useful for somebody.

BTW, with local elements: If you have two locally declared element types
named "foo", do you want a template for each of them then?

Soren
 
K

KJ

Well, here's the reason I asked. Since I'm in the habit of transforming
xml docs using the xsl:template paradigm (if it can be called that), it
would be nice if a program had a feature whereby I could provide the
program with any xsd, and the program would generate a xslt file with
(at least) an <xsl:template> for each element that would match all
instances of the xsd.

I tried Altova's StyleVision, which generates xslt from an xsd,
however, it relies heavily on the xsl:for-each "paradigm".
 
M

Malcolm Dew-Jones

KJ ([email protected]) wrote:
: I would like to know if there is a tool for download or purchase that
: will generate a skeleton xslt document, inserting all the
: xsl:template's matching each element specified in any given xsd.

: Does anyone know of one?

No. But it doesn't sound difficult.

If you post a couple of simple xsd example files and the result you want,
then someone might give a few examples of how to do that based on those
examples.

(No promises.)
 
S

Soren Kuula

KJ said:
Well, here's the reason I asked. Since I'm in the habit of transforming
xml docs using the xsl:template paradigm (if it can be called that), it
would be nice if a program had a feature whereby I could provide the
program with any xsd, and the program would generate a xslt file with
(at least) an <xsl:template> for each element that would match all
instances of the xsd.

I tried Altova's StyleVision, which generates xslt from an xsd,
however, it relies heavily on the xsl:for-each "paradigm".
OK, so I take it is really mostly a matter of generating some empty code
skeletons...

Hey, you might actually make an xslt for that. There is some way (output
namespace aliasing or somthin', can't remember the details) to tell an
xsl processor "this (result tree fragment / sequence) is not an xsl
instruction for you, even though it's in the xsl namespace and really
looks like an xsl instruction". But of course xsd includes and imports
might be a bitch.

BTW, for-each can always be translated to template matching, unless on
the (pathological??) namespace axis. You can always do

<xsl:template match="pattern">
....
<xsl:for-each select="exp">
<t/>
</xsl:for-each>
....
</xsl:template>

to
<xsl:template match="pattern">
....
<xsl:apply-templates select="exp" mode="some_fresh_mode"/>
....
</xsl:template>

<xsl:template match="node()" mode="some_fresh_mode">
<t/>
</xsl:template>

(just FYI -- except for that namespace axis, there is nothing for-each
can do that templates can't do).

OK, I think it seems like a pretty simple task :) One could easily hack
up something to make that, have a go at it :)

Soren
 

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

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top