|
Subject: RE: [xsl] Translating XSD into an XSLT, experts approach needed From: "Andrew Welch" <AWelch@xxxxxxxxxxxxxxx> Date: Thu, 26 Feb 2004 09:23:05 -0000 |
> - I am attempting to automatically generate an XSLT style
> sheet that will render all the elements in an XML document as
> HTML (The XML instance document has already been created and
> does not have to be generated by the system). The visual
> display format is not pre-defined, and the output does not
> have to look good, just display all the data in the XML
> document as HTML.
...but saying 'just display all the data in the xml as html' doesn't
mean anything. You could just wrap any text content in a <div>:
<xsl:template match="text()">
<div>
<xsl:value-of select="."/>
</div>
</xsl:template>
Or just wrap the entire text content in one <div>
<xsl:template match="/">
<div>
<xsl:value-of select="."/>
</div>
</xsl:template>
Both will meet your requirements (as they stand) but both aren't really
what you mean, I think.
> - Rather than automatically generating the XSLT from an XML
> instance document (which could potentially not contain every
> element defined in the schema i.e. if an element is optional)
> instead use the XSD as a reference to ensure every possible
> element has a template associated with it.
Yes, but you need to know how to *style* each element as well. You need
both the XSD and a style guide to create a stylesheet.
> - The generated XSLT can then be applied to any instance
> document to display the data contained within as HTML.
You don't need a schema/dtd to write a stylesheet that will do that.
> The main question I have is if you had to preform this task
> (generate an XSLT to display all elements, using the schema
> as a reference), how what technique would you use? Would you
> systematically work your way through the XSD creating a
> template for each element, or would you first extract certain
> elements?
Well that depends on the output required / styleguide requirements.
Whether you 'push' or 'pull' depends on the structure of your input
*and* on the structure of your output, you can't decide these things on
the schema alone.
> I was also looking for any comments on the viability of such
> a project, or general XSLT construction techniques or
> problems that you think would prove tricky for such a system.
Double click an xml file in windows and you will see a generic display
for xml. Type 'res://msxml3.dll/DEFAULTSS.xsl' into your browser to
view this stylesheet, its probably what you are after. This is a wd-xsl
stylesheet, someone has done an xslt version which of course is better
:)
cheers
andrew
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| RE: [xsl] Translating XSD into an X, Michael Kay | Thread | [xsl] How Do I Exclude Portions Of , Gary Fix |
| RE: [xsl] Embedded Xsl, Michael Kay | Date | RE: [xsl] Translating XSD into an X, Michael Kay |
| Month |