The personal and professional ramblings of Nicholas Chase
Looking for help with one of my books? Try here. Like science fiction? Check out the
Vanguard Science Fiction Report. Looking for XML information? Try the XML Reference Guide. How about Native American books, music, videos, and so on? Try The Native Path.
"Problems cannot be solved at the same level of awareness that created
them." -- Albert Einstein
October 29, 2004
XSLT vs XForms
Don wrote:
>
> Nick
>
> I've been searching around like a dog after a lost bone for something to help explain to me the difference between XSLT and XForms. Why do both exist, and why would someone use one over the other. I have come up fairly dry on this topic, so I wondered if you might have seen some such comparison or explanation somewhere.
>
> Thanks for any input.
>
> Don
Don --
I don't know if anyone has ever talked about this, but I'll try to answer your question here:
The difference in XSLT and XForms is in what they're for. Extensible Stylesheet Language for Transformations (XSLT) is a language specifically designed to take XML of one form or structure and convert it into XML of another form or structure. (You can also use it to convert to and from non-XML, but that's another conversation.) There is a specific "vocabularly" for XSLT, and each element and attribute is focused on transforming a source document into a target document. XSLT deals with all kinds of information and doesn't really try to draw any meaning from it; it simply converts the source into the target.
XForms, on the other hand, is meant to provide an easy way to take information that starts out not as XML, but as data in a user's head. Think of it as HTML forms on steroids. It has a specific vocabulary, meant to be interpreted by an XForms client such as a browser. The client acts on the XForms elements directly, using them to render in some way form entry fields such as text boxes and pulldown menus. It then gathers the individual pieces of information and (in most cases) turns them into XML.
I've personally never seen too much of a collision between the two technologies, but I suppose I can see it if you look at them both as ways of taking information in one form and converting it to some other form. In reality, though, they serve very different purposes. XSLT is an almost abstract language that works directly on the data, where XForms is a concrete language acted upon by a client to help facilitate the actual collection of data.
I hope that helps...
---- Nick
Posted by roadnick at
10:20 PM
|
Comments ()
|
TrackBack
August 10, 2004
Overriding Java's base classes
> Hi Nicholas
>
> First I want to commend you for the excellent book. I was trying to run the sample on using Traversal on the DOM according to the DOM 2.0 recommendation. I am using Java SDK 1.4.2_03. I have attached the source code of the program I am using. I am running on a Windows XP laptop
>
> I am getting an error message
>
> C:\JXML\test17>java ShowDocument
>
> supported
>
> Exception in thread "main" java.lang.ClassCastException
>
> at ShowDocument.main(ShowDocument.java:45)
>
> Regards and Thanks - Ranjan
Hi, Ranjan!
The problem may be related to a bug that made it into Java's XML implementation. Java looks at its base classes, and then the classpath, so just replacing the offending classes on the classpath won't help. To solve the problem, download Xerces from xml.apache.org and use the "Endorsed standards" mechanism to make Java look at it first. To do that, you'll need to set the -Djava.endorsed.dirs switch. For
example, say your xerces.jar, xmlParserApis.jar, or whatever jars come with Xerces these days, are in C:\Xerces\lib. You would call your Java program using:
java -Djava.endorsed.dirs=C:\Xerces\lib ShowDocument
Please let me know if this solves your problem, and thanks for the kind words!
---- Nick
[NOTE: It turned out to be a permissions problem on the database, but the tip still stands. :) ---- Nick]
Posted by roadnick at
10:50 AM
|
Comments ()
|
TrackBack
June 16, 2004
Checkboxes and missing values
Hi
Just read your article on php and forms. Thanks for putting such a resource on the web. Just one quick question though. I don't want to have a check box initially checked but when I leave it blank it doesn't show up in the results. I am trying to produce a csv so this leaves me with one less coloum.
Is there a way around this
Thanks
David
Hi, David!
The nature of checkboxes is that they only show up if they're selected. You can either use a radio button instead, or you can stay with the checkbox but also include an empty hidden field of the same name. That way there's always a "value" with that name, even if the checkbox doesn't come through. Be careful, though, you'll then have to deal with multiple values for a
single field.
I hope that helps!
---- Nick
Posted by roadnick at
12:46 PM
|
Comments ()
|
TrackBack
March 04, 2004
Retrieving DTDs
John wrote:
> Hi Nicolas,
> I wonder if you could answer a problem I am having
> processing an XML file with a Java application. The
> XML file is ejb-jar.xml. There is a line referencing a
> DTD e.g.
> "http://java.sun.com/dtd/ejb-jar_2_1.dtd">.
> However, when my internet connection or java.sun.com
> is down, I am unable to retrieve the dtd and thus get
> a FileNotFoundException. I have tried saving the dtd
> in the java classpath with no success. The error
> occurs when I call: builder.parse(new
> File("ejb-jar.xml"));
>
> Any suggestions or comments would be appreciated.
> thanks.../john
Hi, John!
The trouble is that the parser is trying to retrieve the file
from http://java.sun.com/dtd/ejb-jar_2_1.dtd. You can solve
this problem by saving a local copy to the same directory as
the XML file and changing the DOCTYPE declaration to read
"-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN"
"ejb-jar_2_1.dtd">
I hope that helps!
---- Nick
Posted by roadnick at
10:55 AM
|
Comments ()
|
TrackBack
December 22, 2003
Reader questions
Ever since I wrote my first book, I've been getting letters from readers, which is terrific. Most of the time, they have questions in them, and sometimes the answers are helpful to others as well, so I've decided to post those here. To distinguish for thsoe who may be reading via aggregator, I'll be signifying them by starting the subject with Q:. If you find this helpful, please let me know. Ditto if you find it more annoying than helpful.
Posted by roadnick at
12:47 AM
|
Comments ()
|
TrackBack
Q: Loading an XML document
> Hello professor Nicholas... I´ve read your tip "Traversing an XML document
> with a TreeWalker", and I have a doubt... where in the code, do I load the
> XML file that I want to traverse...?
> In the paper I didin´t see it!
> thanks for your attention!!
The document will be loaded when you parse it, just as you'd parse any DOM document.
---- Nick
Posted by roadnick at
12:01 AM
|
Comments ()
|
TrackBack
December 21, 2003
Q: Using XQuery
> Hi,
>
> I just implemented a Web Service using your tutorial "Send and receive SOAP messages with SAAJ". Thanks for a great and easy tutorial. However, I would like to ask the following:
> How do I validate the incoming request on the server? Must I parse the enclosed SOAP request message and then relate it to the schema? (In my example I would assume I would have to use the RPGService.class. The account number must be 17 characters. I know how to do this using a schema, but that also means I have to know what the request is ie the XML document). Could you please show me how. Hope I explained myself O.K.
>
> Hope to be hearing from you soon.
You can parse the document after you've received it, or
you can set up the web service to reject the request if
it doesn't comply with the schema. One easy way to do
that is to generate a proxy for your service using a
product such as Axis (available at
http://ws.apache.org/axis/index.html). It generates
the proxy based on the WSDL file, which includes the
schema information.
I hope that helps....
---- Nick
Posted by roadnick at
11:58 PM
|
Comments ()
|
TrackBack