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 <a1element 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 ł formolad fil híc &ersir; conna
bitís gnee fortcheda<lb n="432"/><pb n="16"/foi sin dichned
&ersir; dochned &ersir; cennacros <frn lang="la">ut
q<ex>u</ex>idam d<ex>icu</ex>nt</frn>.<lb n="433"/bid
da<ex>no</exné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</addséol siraichthe. <add type="gloss"
hand="M">ł 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</adda scáil
<add type="gloss" hand="M">.i. a fir</adddía coemchill</l>
</lg>
</body>
</text><lb n="438"/>.i. am<ex>al</extéit carpat <add type="gloss"
hand="M">ł claidab</addserda 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></addsund
<sic>incond</sicilid. ar is cul in foc<ex>ul</exgnáthach<lb
n="441"/acht ro thuill in filí .u. sund do línad na filidechta.
ł do<lb n="442"/dúaichnigud na foc<ex>u</ex>l tría
dígbail &ersir; tria tórmach &ersir; tria<lb n="443"/>
inchumscugud do dénam intib &ersir; atát trí gnee fair .i.<lb
n="444"/díchned <add type="gloss" hand="M">ł
dechned</add&ersir; dochned &ersir; cennachros. Is é in
dichned <add type="gloss" hand="M">.i. dicennad</adda<lb n="445"/>
chend do gait dond c<ex>u</ex>l &ersir; 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">ł bi</addba bés
ni thías.</l>
</lg>
</body>
</text>
</p>
///Peter