Subject: RE: Meta XSL From: "Vun Kannon, David" <dvunkannon@xxxxxxxx> Date: Wed, 3 Mar 1999 16:25:06 -0500 |
I know I'm jumping in a bit late on this thread. Others have already posted solutions using two namespaces. I prefer to avoid all namespaces except for the default namespace and write out the result elements longhand (<element name="foo"/> instead of <foo/>). This also helps me keep track of things when my head starts to hurt. As an example, here is a toy stylesheet that emits a recogniser stylesheet, given a DTD written in instance syntax. <!-- rewrite DTD in XML form --> <doctype root="form" system="form.dtd"> <element name="form"> <attribute name="method" exist="implied"> <or> <value>get</value> <value default="true">post</value> </or> </attribute> <attribute name="action" exist="required"><cdata/> </attribute><sequence> <instance name="header"/> <literal min="0" max="1">green</literal> <instance min="0" max="*" name="input"/> </sequence> </element> </doctype> <!-- a stylesheet that is a generic "recogniser" --> <stylesheet xmlns="http://www.w3.org/TR/WD-xsl"> <template match="/"> <element name="stylesheet"> <attribute name="xmlns">http://www.w3.org/TR/WD-xsl</attribute> <element name="template"> <attribute name="match">/</attribute> <for-each select="//element"> <element name="for-each"> <attribute name="select"><value-of select="@name"/></attribute> <for-each select="//attribute"> <element name="for-each"> <attribute name="select"><value-of select="@name"/></attribute> </element> </for-each> </element> </for-each> </element> </element> </template> </stylesheet> Here is the result of applying the stylesheet to the DTD document, a stylesheet that recognises instances of that DTD. <stylesheet xmlns="http://www.w3.org/TR/WD-xsl"> <template match="/"> <for-each select="form"> <for-each select="method" /> <for-each select="action" /> </for-each> </template> </stylesheet> Go ahead and blow holes in my "DTD in XML" syntax and quality of output stylesheet. This is only a demonstration of using XSL to write XSL. But, if you took this line of thinking seriously, you could create the equivalent of Oracle's recently announced "XML Class Generator" with a stylesheet, a stylesheet that reads DTDs and emits Java source code. Prerequisite: a good rewrite of DTD syntax into document instance syntax. Cheers, David vun Kannon Manager, Financial Services Consulting KPMG LLP > -----Original Message----- > From: Toivo Lainevool [SMTP:tlainevool@xxxxxxxxx] > Sent: Sunday, February 28, 1999 7:28 PM > To: xsl-list@xxxxxxxxxxxxxxxx > Subject: Meta XSL > > I am trying to use XSL to generate an XSL stylesheet. I call > this a meta-XSL stylesheet. I thought that since XSL is valid XML, > this should be possible, but I am having one small > problem. If I have a meta-XSL file that looks like this: > > <meta-xsl:stylesheet xmlns:xsl="foo" > xmlns:meta-xsl="http://www.w3.org/TR/WD-xsl" > result-ns=""> > <meta-xsl:template match='/'> > <xsl:stylesheet> > <html><body>test</body></html> > </xsl:stylesheet> > </meta-xsl:template> > </meta-xsl:stylesheet> > > Running XT on this with any XML file generates the following output: > > <xsl:stylesheet > xmlns:xsl="foo"><html><body>test</body></html></xsl:stylesheet> > > The problem is I need the "xmlsn:xsl" attribute of the stylesheet > element > in the output to be "http://www.w3.org/TR/WD-xsl" instead of "foo". > > If I try to specify the URI in the meta-XSL stylesheet like this: > > <meta-xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl" > xmlns:meta-xsl="http://www.w3.org/TR/WD-xsl" > result-ns=""> > > XT tries to interpret the "xsl" elements in the meta-XSL file as > valid XSL so it fails. > > I know I could run the produced XSL through a quick post-processing step > to add in the right string into the attribute, but I am trying to find a > "pure" XSL solution. > > I can get a stylesheet produced that uses the default namespace. If I > use: > > <meta-xsl:stylesheet > xmlns:meta-xsl="http://www.w3.org/TR/WD-xsl" > result-ns=""> > <meta-xsl:template match='/'> > <meta-xsl:element name="stylesheet"> > <meta-xsl:attribute > name="xmlns">http://www.w3.org/TR/WD-xsl</meta-xsl:attribute> > <html><body>test</body></html> > </meta-xsl:element> > </meta-xsl:template> > </meta-xsl:stylesheet> > > XT produces: > <stylesheet > xmlns="http://www.w3.org/TR/WD-xsl"><html><body>test</body></html> > </stylesheet> > > Which when itself run through XT fails because the HTML elements are now > in the wrong namespace. If I could get a XSL stylesheet that use the > default namespace to specify xsl elements and still produce valid HTML, > it would be a step in the right direction. > > There is a thread going on in the list about the use of the result-ns > attribute, > would it make sense to be able to specify "xsl" as the result type of > an xsl transformation? > > Any help with this would be greatly appreciated. > > As a side note, it is interesting to think about trying to be able to > produce _any_ valid XML document via XSL, and this case being the > proof of Godel's Incompleteness Theorem for XSL. > > Thanks, > > Toivo Lainevool > > > > > _________________________________________________________ > DO YOU YAHOO!? > Get your free @yahoo.com address at http://mail.yahoo.com > > > XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list ***************************************************************************** The information in this email is confidential and may be legally privileged. It is intended solely for the addressee. Access to this email by anyone else is unauthorized. If you are not the intended recipient, any disclosure, copying, distribution or any action taken or omitted to be taken in reliance on it, is prohibited and may be unlawful. When addressed to our clients any opinions or advice contained in this email are subject to the terms and conditions expressed in the governing KPMG client engagement letter. ***************************************************************************** XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
MTG ANN: Portals to the Web at the , Chet Ensign | Thread | xsl:element usage, Mark_Ulferts |
MTG ANN: Portals to the Web at the , Chet Ensign | Date | xsl:element usage, Mark_Ulferts |
Month |