Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: XSLT from a XSD spec.

From: Peter Flynn <peter.nosp@-.--------.-->
To: NULL
Date: 10/4/2006 11:13:00 PM

Gilgamesh wrote:
> Hi.
> 
> I'm looking for an easy way to generate, automatically, an XSLT from an
> XSD, to be applied to a XML file (conforming the previous XSD) and
> generate an HTML.  Many of you will tell me that this is nonsense, 

Usually because there is no obvious way to know what HTML
your <a1> element type ought to be output as, for example.

There is an infinite number of ways of doing it, so how do
you decide what is the "right" way for arbitrary XML.

I agree that if the element type names have an accepted
meaning in some language (eg <para>) then some of the
decisions are obvious, but more often they are not.

> I think it can be done, given the condition that the XML file (as
> specified in the XSD) always has a root element (although it would be
> nice if the root element name could be a parameter of the XSLT), 

The root element name of an XML document is always given
by the XPath expression /*[1]/name()

> and a
> given hierarchy of sub-elements, until a level N where there is a list
> of data elements, like this:
> 
> <root>
>   <a1>
>     <b1>
>       <c1>
>         <d>D Value</d>
>         <e>E Value</e>
[snip]

But what makes you think all document types follow this pattern?
What you ask for may be valid for a very restricted subset of highly
specialist document types, but here's a paragraph of the kind of
XML I deal with:

<p><lb n="431"/>Fortched &lstrok; formolad fil híc &ampersir; conna
   bitís gnee fortcheda<lb n="432"/><pb n="16"/> foi sin dichned
   &ampersir; dochned &ampersir; cennacros <frn lang="la">ut
     q<ex>u</ex>idam d<ex>icu</ex>nt</frn>.<lb n="433"/> bid
   da<ex>no</ex> néit guin <frn lang="la">ut
     d<ex>icitu</ex>r</frn><text type="poem">
     <body>
       <lg type="quatrain" met="deibide">
	<lb n="434"/>
	<l>ro bé do lecht i farthe <add type="gloss" hand="M">.i. i
	    mmochai</add></l>
	<lb n="435"/>
	<l>iar do néit <add type="gloss" hand="M">.i. iar do
	    guin</add> séol siraichthe. <add type="gloss"
	    hand="M">&lstrok; sírarde</add></l>
	<lb n="436"/>
	<l>ructhar i capp <add type="gloss" hand="M">.i. i carr</add>
	  i ndiaid phill <add type="gloss" hand="M">.i. eich</add></l>
	<lb n="437"/>
	<l>do racc <add type="gloss" hand="M">.i. do ben</add> a scáil
	  <add type="gloss" hand="M">.i. a fir</add> día coemchill</l>
       </lg>
     </body>
   </text><lb n="438"/>.i. am<ex>al</ex> téit carpat <add type="gloss"
     hand="M">&lstrok; claidab</add> serda tré chath corop amlaid<lb
     n="439"/> dech m'animsea tría chath nemna dochum nime. Culu<lb
     n="440"/> .i. forthched <add type="gloss" hand="M">.i. deichned
     <frn lang="la">specialit<ex>er</ex></frn></add> sund
   <sic>incond</sic> ilid. ar is cul in foc<ex>ul</ex> gnáthach<lb
     n="441"/> acht ro thuill in filí .u. sund do línad na filidechta.
   &lstrok; do<lb n="442"/> dúaichnigud na foc<ex>u</ex>l tría
   dígbail &ampersir; tria tórmach &ampersir; tria<lb n="443"/>
   inchumscugud do dénam intib &ampersir; atát trí gnee fair .i.<lb
     n="444"/> díchned <add type="gloss" hand="M">&lstrok;
     dechned</add> &ampersir; dochned &ampersir; cennachros. Is é in
   dichned <add type="gloss" hand="M">.i. dicennad</add> a<lb n="445"/>
   chend do gait dond c<ex>u</ex>l &ampersir; cen ní ele ina inad <frn
     lang="la">ut dixit<lb n="446"/> poeta</frn>.<text type="poem">
     <body>
       <lg type="quatrain">
	<lb n="447"/>
	<l>Dál ro dálus mór in baes</l>
	<lb n="448"/>
	<l>isind arus huas Druim <sup resp="BB">Lias</sup></l>
	<mls n="7a" unit="folio"/>
	<lb n="449"/>
	<l>a mmo chomdiu a ri .rú. rá. <add type="gloss" hand="M">.i.
	    rún .i. rathmar sa</add></l>
	<lb n="450"/>
	<l>bui biu <add type="gloss" hand="M">&lstrok; bi</add> ba bés
	  ni thías.</l>
       </lg>
     </body>
   </text>
</p>

///Peter


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent