Re: W3C Schema to HTML form.Generic solution available?
"Kwon J. Ekstrom" <[email protected]> Tue, 2 Dec 2003 14:36:17 -0700
| Newsgroups | gmane.comp.java.sun.xml.general |
|---|---|
| Message-ID | <[email protected]> |
Haven't read that book, but I generally find Wrox books to be beginnerish. The w3schools tutorial is IMHO enough to get you started, and from there a good reference is all you need. I'd highly recommend the O'Reilly XSLT books, they've always seemed more practical to me. Either way, it's been a long time since I've had to consult a book to write XSLT, considering I've been using it almost since it was a draft. Schema's on the list of need to learns, as you say... DTD is going away. But it's hardly a priority as there are many things higher on my list to learn. -- Kwon J. Ekstrom Mark Galbreath wrote: > Just grab the latest edition of Michael Kay's book - it's the bible of XSLT. > I have the 2d edition (Wrox 2001), which is probably the latest. > > As for learning XML schema, you better - DTDs are history. > > Mark > > -----Original Message----- > From: XML technologies in the Java Platform > [mailto:[email protected]]On Behalf Of Kwon J. Ekstrom > Sent: Tuesday, December 02, 2003 3:02 PM > To: [email protected] > Subject: Re: W3C Schema to HTML form.Generic solution available? > > > IMHO, XSLT is the best tool, I don't personally know XML Schema yet > (having not had a driving reason to learn it, although it's on the list). > > First off, since you mention some difficulty understanding how XSLT > works. From an OO perspective, think of the XML as a tree based data > source, and your XSLT as your application. > > Each template is essentially a function, which can be called by applying > on a matching node, or by being called directly by name. > > You can assume that each template is also an object with the properties > of the element it is being applied to. > > The xsl:param/with-param elements allow passing variables between > functions. Note that these can be viewed as "optional" arguments, with > a default specified by the child nodes, or the xpath contained in a > select attribute. > > XPath essentially acts as a search algorithm for any matching nodes. > It's really where I'd suggest concentrating XSL research. Most of the > power of XSL comes from XPath. > > This is a very rough explaination, and not entirely accurate, but should > serve to help you find some common ground. > > Since you don't have previous XSLT experience, I suggest you try to > write templates based on the direct output. > > Take a look at the example schema found at: > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/xmlsdk/htm/ > xsd_ref_01mb.asp > > At the end of this email, I've pasted in the xml on that page, along > with a template that works with it. > > However, you can use either a passed in parameter or the document xpath > function to load your schema as a second document. Assuming you wish to > try it, you can use a technique that I call cross-templating to write a > generic schema template. > > Although I doubt such an effort would be worth the results, as it would > handle building the forms and validation, but most likely wouldn't do so > in a user friendly manor (UI is the major concern here). > > The purpose here I assume is to increase productivity. If you'd like > more information, I'd be happy to post some examples. > > -- Kwon J. Ekstrom > > amol wrote: > > >>Thanks Roy. >>I did go through this series of articles but its too specific to the >>example xml document in the article. >>I guess the solution would be to write a XSL which transform the schema >>into xhtml form. >>But I am sure someone must have already done this since it looks like a >>common problem. >>yups..am basically OO programmer. Just today I went through the >>XSL tutorial on w3school (http://www.w3schools.com/xsl/) Pretty >>informative and concise. >>Still grappling for a solution..... >> >> >> ----- Original Message ----- >> *From:* Roy Jacob <mailto:[email protected]> >> *To:* [email protected] <mailto:[email protected]> >> *Sent:* Tuesday, December 02, 2003 2:58 PM >> *Subject:* Re: W3C Schema to HTML form.Generic solution available? >> >> Hi. >> Have a look at this and the following articles. >> http://www.xml.com/pub/a/2003/04/30/editing.html >> >> It's not the answer you are looking for but it may help you develop >> your own solution. I'm in a similar boat to you and have been using >> these articles for referance. If your a classical OO programmer like >> me the XSL learning curve is V steep! >> >> Roy. > > > <?xml version="1.0" encoding="UTF-8" ?> > <xsl:stylesheet version="1.0" > xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> > <xsl:template match="purchaseOrder"> > <table> > <tr><td colspan="2">Order Date: <xsl:value-of select="@orderDate" > /></td></tr> > <tr> > <td> > <xsl:call-template name="USAddress"> > <xsl:with-param name="addr" select="shipTo" /> > </xsl:call-template> > </td> > <td> > <xsl:call-template name="USAddress"> > <xsl:with-param name="addr" select="billTo" /> > </xsl:call-template> > </td> > </tr> > <tr><td colspan="2"><xsl:value-of select="comment" /></td></tr> > <tr><td colspan="2"> > <xsl:apply-templates select="items" /> > </td></tr> > </table> > </xsl:template> > > <xsl:template match="items"> > <table width="100%" border="1" cellspacing="1"> > <tr> > <th>Part #</th> > <th>Product</th> > <th>Quantity</th> > <th>Price</th> > <th>Ship Date</th> > <th>Comment</th> > </tr> > <xsl:apply-templates select="item"> > <xsl:sort select="USPrice" order="descending" /> > </xsl:apply-templates> > <tr> > <td></td> > <td></td> > <td><xsl:value-of select="sum(item/quantity)" /></td> > <td><xsl:value-of > select="format-number(sum(item/USPrice),'$#,##0.00')" /></td> > <td></td> > <td></td> > </tr> > </table> > </xsl:template> > > <xsl:template match="item"> > <tr> > <td><xsl:value-of select="@partNum" /></td> > <td><xsl:value-of select="productName" /></td> > <td><xsl:value-of select="quantity" /></td> > <td align="right"> > <xsl:value-of select="format-number(USPrice,'$#,##0.00')" /> > </td> > <td> > <xsl:value-of select="shipDate" /> > <xsl:text disable-output-escaping="yes">&nbsp;</xsl:text> > </td> > <td> > <xsl:value-of select="comment" /> > <xsl:text disable-output-escaping="yes">&nbsp;</xsl:text> > </td> > </tr> > </xsl:template> > > <xsl:template name="USAddress"> > <xsl:param name="addr" /> > <xsl:value-of select="$addr/name" /><br /> > <xsl:value-of select="$addr/street" /><br /> > <xsl:value-of select="$addr/city" />, > <xsl:text> </xsl:text><xsl:value-of select="$addr/state" /> > <xsl:text disable-output-escaping="yes">&nbsp;&nbsp;</xsl:text> > <xsl:value-of select="$addr/zip" /> > </xsl:template> > > </xsl:stylesheet> > > ---------------------------------------------------------------------------- > <?xml version="1.0" encoding="UTF-8" ?> > <?xml-stylesheet type="text/xsl" href="test1.xslt" ?> > > <purchaseOrder orderDate="1999-10-20"> > <shipTo country="US"> > <name>Alice Smith</name> > <street>123 Maple Street</street> > <city>Mill Valley</city> > <state>CA</state> > <zip>90952</zip> > </shipTo> > <billTo country="US"> > <name>Robert Smith</name> > <street>8 Oak Avenue</street> > <city>Old Town</city> > <state>PA</state> > <zip>95819</zip> > </billTo> > <comment>Hurry, my lawn is going wild!</comment> > <items> > <item partNum="872-AA"> > <productName>Lawnmower</productName> > <quantity>1</quantity> > <USPrice>148.95</USPrice> > <comment>Confirm this is electric</comment> > </item> > <item partNum="926-AA"> > <productName>Baby Monitor</productName> > <quantity>1</quantity> > <USPrice>39.98</USPrice> > <shipDate>1999-05-21</shipDate> > </item> > </items> > </purchaseOrder> > > ----------------------------------------------------- > xml-interest: A list for discussing XML technologies in the Java Platform. > To post, mailto:[email protected] > Archives at: http://archives.java.sun.com/xml-interest.html > To unsubscribe, mailto:[email protected] the following message; > signoff xml-interest. > > ----------------------------------------------------- > xml-interest: A list for discussing XML technologies in the Java Platform. > To post, mailto:[email protected] > Archives at: http://archives.java.sun.com/xml-interest.html > To unsubscribe, mailto:[email protected] the following message; > signoff xml-interest. > ----------------------------------------------------- xml-interest: A list for discussing XML technologies in the Java Platform. To post, mailto:[email protected] Archives at: http://archives.java.sun.com/xml-interest.html To unsubscribe, mailto:[email protected] the following message; signoff xml-interest.