Click to See Complete Forum and Search --> : Basic XML Questions
brendandonhue
05-11-2003, 09:21 AM
This summer I will be doing web design for a jeweler.
I was thinking of using XML to keep track of the products/prices/info. Say the XML file looked like this. (I don't know the XML syntax yet, this is just a sample!).
<item>
<productid>001</productid>
<name>Product Name</name>
<price>Price</price>
</item>
Do you think XML would be work well for this project? If I don't use XML, I would just be using HTML and doing a page for each product, as I dont need a full blown database.
And how would I take that XML file, and transform it into this?
Product ID:001
Name: Product Name
Price: Price
Would I use XSL to parse/display the data?
BTW I don't need like, exact code on how to do this, just someone to point me in the right direction so I can learn this.
I have already started looking at the W3Schools tutorials on XML.
Thx in advance :)
khalidali63
05-11-2003, 04:23 PM
I wrote an extermely flexible solution for this member,take a look at this thread..
http://forums.webdeveloper.com/showthread.php?threadid=9363
Works both on IE and NS,and you don't have to worry about learning any other language ,such as xsl and stuff,just plain old JavaScript and DOM will do.
:D
brendandonhue
05-12-2003, 05:16 AM
Thanks, Sounds great from that thread, but your site seems to be down :(
I have gone to other pages hosted on your server (im guessing that the IP is you running it yourself).
Ill try again a little later.
Charles
05-12-2003, 06:28 AM
Originally posted by khalidali63
[J]ust plain old JavaScript and DOM will do. Yes, but one in ten users do not use "plain old JavaScript and DOM" and that one in ten users includes persons with disabilities who cannot use "plain old JavaScript and DOM". As such that solution could cause the page to violate accessibility laws and certainly wouldn't be very nice. As this is to keep track of "products/prices/info" if this is in the US then Title III of the Americans with Disabilities Act would definitely apply and possible Title I as well. Just go ahead and learn XSLT. It's a pretty quick learn and rather useful.
khalidali63
05-12-2003, 09:00 AM
yes,the web page is up...sowwy..:D
brendandonhue
05-12-2003, 05:57 PM
Ok thanks! Looks pretty neat khalidali.
Although I read some tuts on XSLT and that may be the way to go if Charles is correct about those laws.
Charles-I have seen you post maybe a dozen times that something will not work for 1 in 10 users. I was wondering what exactly it was your referring to when you say that 1 in 10. Is it text only/aural browsers, or disabled javascript or something?
khalidali63
05-12-2003, 06:15 PM
Originally posted by brendandonhue
Ok thanks! Looks pretty neat khalidali.
........
As we all know,there are a tonnes of options out there when you look for coding,it all comes to the final point that what exactly suites your requirements.
XML/XSL an ultimate option without getting worried about any browser compliance problems...
JavaScript/XML is only an additional option for users,if charles has something against it why don't he sue MS,who to begin with created the XML data island idea and created a proprietery tag.
The solution I provided is only intended for people who deem this appropriate for them,for the others all the rest of the options are open for chosing.
Charles
05-12-2003, 06:17 PM
Currently about one in ten users do not use JavaScript (http://www.thecounter.com/stats/2003/May/javas.php). And because some of those users are disabled and cannot use JavaScript you are not supposed to rely upon it (http://www.w3.org/TR/WCAG10/wai-pageauth.html#tech-scripts) And because of the Americans with Disabilities Act (http://www.usdoj.gov/crt/ada/pubs/ada.txt) if you are in the US you might be facing a lawsuit if your web site does rely upon it (http://www.usdoj.gov/crt/foia/tal712.txt). Other countries have other accessibility laws that apply so be careful.
khalidali63
05-12-2003, 06:19 PM
As we all know,there are a tonnes of options out there when you look for coding,it all comes to the final point that what exactly suites your requirements.
XML/XSL an ultimate option without getting worried about any browser compliance problems...
JavaScript/XML is only an additional option for users,if charles has something against it why don't he sue MS,who to begin with created the XML data island idea and created a proprietery tag.I thought I did a great job in creating a NS compatible code that works in IE as well,for those who like to use DOM methods to manipulate the xml with javascript.
The solution I provided is only intended for people who deem this appropriate for them,for the others all the rest of the options are open for chosing.
Charles
05-13-2003, 05:17 AM
When you post some code or a method that is hurtful to people (and inaccessible pages do hurt the disabled) or that might expose the web author to lawsuits you at least have an obligation to warn them. "Do no harm" as it were. And perhaps you have an obligation to not post harmful code or methods at all but to promote better web practices.
And see http://www.evolt.org/article/Accessibility_Laws_In_Canada/4090/28074/ for a review of the state of Internet accessibility law in Canada.
brendandonhue
05-13-2003, 02:26 PM
Ok thanks.
I think it would just be best to use XSL, don't want any legal problems, as I don't think I am even of legal age to be working :rolleyes:
AdamGundry
05-13-2003, 03:19 PM
I don't think I am even of legal age to be workingWhich country are you in? In the UK, you have to be 14 to work part time, for limited hours. I probably sometimes break the law, but I am working for myself, and as I'm under 18 I can't be sued. Isn't the law great. :)
I agree with Charles, you should not use Javascript for page content because it limits your audience, and is unfair (legal or not). Use JS for added interactivity, but the content should be available to everyone.
Adam
brendandonhue
05-13-2003, 03:25 PM
US, and just turned 13.
I know I can legally work part time at 14.
Hester
06-09-2003, 05:11 AM
If you follow the W3C Accessibility Guidelines I believe they say that if you do use Javascript, then make sure an identical page made without it is available.
I have two pages on my work site that use drop down menus and Javascript to make them link to other documents. It's the best solution in terms of space and presentation, what the client wanted. But I also have a message that comes up when Javascript isn't used offering a link to the same page, but with the menus turned into simple links.
I've just made the pages run from XML so I don't have to manually update two pages at once.
He guys, I've followed this thread, and I'd like to know what XSLT is, and how it provides a way to, not using Javascript (?), read and process XML documents and print them as HTML markup (am I right?). If I'm not mistaken, XSLT is XML "stylesheets," that provide a way for XML to be parsed... But the question is, how would I go about using it?
I hope to get into XML, because not only does it look really cool and interesting, but it also provides an efficient way for me to store, extract, and process data.
Jona
Okay, I've read up a whole bunch on XSLT (http://www.w3.org/TR/xslt) and found a great link (http://www.xml.com/pub/a/2000/08/holman/) to some XSLT tutorials. Pretty clever...
So I come to find out that XSLT is the "stylesheet" language of XML, and it basically sets the structure in which the data in the XML document is output...
Now, Charles posted a link on the SAXON XSLT Parser... I wanted to know what this parser is needed for? I've created XML and XSLT documents on my local computer, so I know that it's "basically" client-side--but it has no compatibility issues! It's almost like creating your own template for a programming language! That's neat. No wonder it's called the eXtensible Markup Language. :)
All right, so that's basically all I have to say for now... Give me your input, guys! I need it. ;)
Jona
Khalid Ali
06-15-2003, 02:14 PM
XSLT parsers read the xml and apply the xsl/xslt file format to it and produce the desired results.
I think all of the XSL processors take to the most 3 parameters( at least the ones I worked with do)
XSML file XSL file and OTPUT file
All generation 6+ browsers(NS6+ and IE6+) have their built in xsl processor that transforms the xml document according to the xslt file.
Be specific about your quetion..to get more insight on these issues..
:D
Well, ok, it makes sense now why I can use XSLT on IE6 and NS6. Are the two browsers' XSLT processors basically the same or is it like Javascript and back to compatibility issues? Also, for older browsers to support XML, I'd have to use an external XSLT processor like SAXON, right? So finally all I really have to do is use an XSLT processor (SAXON) for all browsers so that I don't have to worry about compatibility, right? I think I'm getting the general idea here... (Right? :D)
Jona
Charles
06-15-2003, 03:58 PM
You can run XSLT three ways:
1) at the browser
2) at the server
3) before you upload to the server.
I use method three, using Saxon to generate a HTML version and often to generate a printer friendly Formatting Objects version which is then processed into PDF.
So then the question would be, is there any "best method"? What are the advantages and disadvantages of each method? Am I right in saying that the "at the browser," method has compatibility issues, the "at the server" method is the dynamic method and the "before uploaded" method is the static method? Are there any other advantages or disadvantages I'm missing?
Thanks for helping guys, I've come across a few things and done a lot with at the browser XML (using IE, I haven't tested anything in NN or Moz yet). As much as creating my own DTD that reads the data and sets up a table with that data, and even adds up the sums. Very interesting how XML/XSLT works. I like it. :D
Jona
Charles
06-15-2003, 04:27 PM
"At the browser" is still a little too iffy. Perhaps one day, but not yet. I don't process at the server because it would be too much of a hassle to get my server guy to get Java up and running. But if my documents were dynamic, then I'd go through the hassle.
By the way, have you discovered the wonder of defining your own entities?
Originally posted by Charles
"At the browser" is still a little too iffy. Perhaps one day, but not yet.
So you mean it's best to go server side for dynamic data?
Originally posted by Charles
I don't process at the server because it would be too much of a hassle to get my server guy to get Java up and running.
Can't you use ASP, PHP, or CGI too?
Originally posted by Charles
By the way, have you discovered the wonder of defining your own entities?
I think I have. :p What exactly do you mean by that?
Jona
Charles
06-15-2003, 04:43 PM
Originally posted by Jona
So you mean it's best to go server side for dynamic data?Yes.Can't you use ASP, PHP, or CGI too?The XSL processors seem to be all written in Java.I think I have. :p What exactly do you mean by that?Here's an actual example from a technical document I've authored:
<!DOCTYPE html SYSTEM "file:///Dtd/xhtml1-strict.dtd" [
<!ENTITY AA '<acronym xml:lang="la" title="Amelanchier arborea 'Autumn Brilliance'">AA</acronym> (Autumn Brilliance Downy Serviceberry)'>
<!ENTITY AR '<acronym xml:lang="la" title="Acer rubrum 'October Glory'">AR</acronym> (October Glory Red Maple)'>
<!ENTITY FP '<acronym xml:lang="la" title="Fraxinus pennsylvanica 'Marshalls Seedless'">FP</acronym>'>
<!ENTITY KP '<acronym xml:lang="la" title="Kolreuteria paniculata">KP</acronym> (Golden Rain Tree)'>
<!ENTITY PA '<acronym xml:lang="la" title="Picea abies">PA</acronym> (Norway Spruce)'>
<!ENTITY PS '<acronym xml:lang="la" title="Pinus strobus">PS</acronym> (White Pine)'>
<!ENTITY QPA '<acronym xml:lang="la" title="Quercus palustris">QPA</acronym> (Pin Oak)'>
<!ENTITY QPH '<acronym xml:lang="la" title="Quercus phellos">QPH</acronym> (White Oak)'>
<!ENTITY UPA '<acronym xml:lang="la" title="Ulmus Parvitolia 'Alee'">UPA</acronym> (Alee Chinese Elm)'>
<!ENTITY ZS '<acronym xml:lang="la" title="Zelokova serata 'Green Vase'">ZS</acronym> (Green Vase Zelkova)'>
<!ENTITY BD '<acronym xml:lang="la" title="Buddleia davidii 'Charming Pink'">BD</acronym> (Butterfly Bush)'>
<!ENTITY bd '<span xml:lang="la" title="Buddleia davidii 'Charming Pink'">Buddleia</span>'>
<!ENTITY HHR '<acronym xml:lang="la" title="Hemercallis 'Happy Returns'">HHR</acronym> (Happy Returns Daylilies)'>
<!ENTITY hhr '<span xml:lang="la" title="Hemercallis 'Happy Returns'">Hemercallis</span>'>
<!ENTITY LS '<acronym xml:lang="la" title="Lirope spicata">LA</acronym> (Creeping Lilyturf)'>
<!ENTITY ls '<span xml:lang="la" title="Lirope spicata">Lirope</span>'>
<!ENTITY NC '<acronym xml:lang="la" title="Narcissus 'Carlton'">NC</acronym> (Carlton Daffidol)'>
<!ENTITY nc '<span xml:lang="la" title="Narcissus 'Carlton'">Narcissus</span>'>
<!ENTITY PNH '<acronym xml:lang="la" title="Pennisetum 'Hameln'">PNH</acronym> (Dwarf Fountain Grass)'>
<!ENTITY pnh '<span xml:lang="la" title="Pennisetum 'Hameln'">Pennisetum</span>'>
<!ENTITY PL '<acronym xml:lang="la" title="Prunus laurocerasus 'Otto Lutyken'">PL</acronym> (Cherry laurel)'>
<!ENTITY pl '<span xml:lang="la" title="Prunus laurocerasus 'Otto Lutyken'">Lauroceraus</span>'>
<!ENTITY FRP '<acronym title="Fiberglass Reinforced Plastic">FRP</acronym>'>
<!ENTITY OM '<acronym title="Operations and Maintaince">O&M</acronym>'>
<!ENTITY RP '<acronym title="Recreation and Parks">R&P</acronym>'>
<!ENTITY SWM '<acronym title="Storm Water Management">SWM</acronym>'>
<!ENTITY ADA '<acronym title="Americans with Disabilities Act">ADA</acronym>'>
<!ENTITY etc '<span xml:lang="la" title="and the rest">et cetera</span>'>
]>
With that in the document prolog, I need only use &PS; whenever I'm refering to a "pinus strobus" with its standard acronym PS and the dang thing will be properly marked up according to Web Content Accessibility Guidelines 1.0. (The document is for an entity covered by Title II of the ADA.)
Yup, I have discovered them! :D In fact, I've used them. It's like creating your own DTD. Very neat! ;)
Originally posted by Charles
Here's an actual example from a technical document I've authored
You've written a book? Cool. May I ask where I may find this book? Also, I'd like to know how you learned Javascript and where from. Did you take it at college or a university?
About the XSLT processors... I thought you could use PHP, ASP or CGI to process XML documents and sort them properly. If I'm not mistaken, that's a part of what this document is about (see brendandonhue's post above). Does this mean that server-side code (PHP, ASP or CGI) must create its own way of processing the XML to act like an XSLT processor, when in fact it is not an XSLT processor?
Jona
Charles
06-15-2003, 05:27 PM
No, I haven't written any books lately, unless you count the way too many posts I've made on these fora. That DOCTYPE is from an internal document that details the stuff the contractor forgot to do when he built a public park.
Another, more interesting project that I have going on is a little something that I worked up for a couple of local churches. The government might say that churches do not have to abide by the ADA, but we have to answer to a higher authority and that presents certain challenges where the congregational calendar is concerned. The final product must be accessible and somebody with limited computer skills has to be able to update it. So, I've created CalendarML and since church calendars have a lot of repetitive events, entities are really useful.
XSLT can be thought of as simply another computer language, one with a specific application. You cannot use Perl as XSLT any more than you can use Perl as PHP. But in the same way that you can do the same things with Perl that you can do with PHP, you can use Perl to transform XML.
Makes very good sense to me. ;) Now that I know all this, I'm going to have to get that SAXON processor thing-a-ma-bob or whatever. :D
Originally posted by Charles
The government might say that churches do not have to abide by the ADA, but we have to answer to a higher authority and that presents certain challenges where the congregational calendar is concerned.
I agree with you there, all the way. ;)
Jona
Charles
06-15-2003, 05:38 PM
http://saxon.sourceforge.net/
http://xml.apache.org/xalan-j/
Originally posted by Jona (me!)
I'd like to know how you learned Javascript and where from. Did you take it at college or a university?
May I ask why you haven't answered this question (now and in the past)? Are you avoiding answering?
Jona
Charles
06-15-2003, 06:22 PM
Originally posted by Jona
May I ask why you haven't answered this question (now and in the past)? Are you avoiding answering?
Jona I'm not so sure that I have learned JavaScript.
I've never taken a class in programming and I'm not a programmer by trade. I just play with it the way some people do crossword puzzles. It's a diversion that doesn't take too much thought. I earned a BA majoring in Philosophy, which means that I'm trained to learn things and to see the world the way other people see it. The trick in using any computer languare is to see the world the way the language does. I read cover to cover JavaScript : The Definitive Guide by david Flanagan a few times and the rest is obvious.
Well, in my opinion we've both basically learned Javascript (note: basically). :)
I'm surprised you haven't taken any college courses or anything on it, but I'm not surprised that it's possible--seeing as that's exactly what I'm doing. :p
Does JavaScript : The Definitive Guide teach the object.event() = function(){}, array-like, and object-oriented programming? Man, I need that book so bad.. OK, I'm off to buy a new hard drive, Photoshop, Flash, Dreamweaver, JavaScript : The Definitive Guide and a bunch of other stuff! lol
Jona
Khalid Ali
06-16-2003, 01:42 AM
Originally posted by Charles
http://xml.apache.org/xalan-j/
Holly cripes Charles...I was getting worried here, that how come you have not mentioned the most powerfull of all parsers(my opinion :D ) so far...
But thanks..now I can go and have a good night sleep.:p
Hester
06-16-2003, 03:56 AM
PHP comes with an XSLT module but it needs to be installed when the Apache PHP program is set up. It also has an XML parser. So this language is superb for XML.
Now Charles, you must tell us what an "Autumn Brilliance Downy Serviceberry" is!
Charles
06-16-2003, 05:16 AM
Originally posted by Hester
[Y]ou must tell us what an "Autumn Brilliance Downy Serviceberry" is! Have you not heard of search engines?
http://www.hcs.ohio-state.edu/plantlist/description/amelanchier.html
brendandonhue
06-16-2003, 06:34 AM
PHP has an XML/XSLT parser and I think I read about one for ASP as well.
Khalid Ali
06-16-2003, 07:01 AM
I know htere were parsers for ...Java C/C++ at least 3 years back(XALAN for java)...
I know I have written code in IE to external XSL and the most famous XML rendering IN IE for which NS had to write their parser so that they can display XML just as in IE..thats all done via XSL parser....I don't think there is any major language for which there is not a XML/XSL parser available...
Charles
06-16-2003, 07:18 AM
A parser is just one part of an XSLT processor. (Saxon uses the Aelfred parser.) You can transform XML with any language, if you have a parser, but you will not be using XSLT.
Boy, do I get the point now! :p All right, so off I go to parse XML via an XSLT processor... And later shall I go through figuring out how to get my server to support Java. (I don't know if that one is possible, until I get a new server.)
I'm also going to use PHP to process XML documents, just for a learning experience.
Thanks for the help,
Jona
Khalid Ali
06-16-2003, 10:39 AM
Use apache webserver it has supportr for php...and you can make tomcat work with apache as well and tomcat is java enabeld web server
Yes, I always go with Apache. ;)
Jona