473,386 Members | 1,610 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Before I Dive In To XML/XSLT

I've got a quick question. I've been using HTML/XHTML for years upon years upon years, and finally used XML for the first time in one of my applications that I developed using Ajax. I fully understand how to write XML, but not so much of XSLT. I took a quick look at XSLT, and I'm a little puzzled on how to do more of the flat out fancy effects that I can do in CSS. Can I do absolutely everything I can do in CSS (opacity, floating, z-index, shadows, etcetera) with XSLT (alone), or not?

If not, is there a way to apply CSS to the XHTML you "generate" using XSLT?
Dec 20 '08 #1
4 1746
Dormilich
8,658 Expert Mod 8TB
you're misunderstanding XSLT. CSS is used to style/layout an existing (XML/HTML) markup. XSLT is used to change the markup itself (thus changing the structure rather than the style, which leads to a different presentation*).

@moltendorf
sure, output an element that's loading the stylesheet. (either <link> or <style>)

* example
Expand|Select|Wrap|Line Numbers
  1. // your xml
  2. <?xml version="1.0" encoding="iso-8859-1" ?>
  3. <root>
  4.   <echo>Hello World!</echo>
  5. </root>
while CSS tells the browser how to display the <root> and <echo> elements, XSLT changes the XML to a (e.g.) HTML
Expand|Select|Wrap|Line Numbers
  1. // XSLT result
  2. <!DOCTYPE ...>
  3. <html>
  4.   <head>
  5.     <title>Example</title>
  6.     <link rel="stylesheet" href="sample.css">
  7.   <head>
  8.   <body>
  9.     <p>Hello World!</p>
  10.   </body>
  11. </html>
note: you can apply XSLT inline so that the sent markup is the same, but the document tree (DOM) the browser loads and uses is the result of the transformation. nevertheless many people prefer to do the transformation server side and only deliver the result (e.g. me).
Dec 20 '08 #2
Ah, alright. I was not confused on how XSLT worked. But more so on the fact that all these tutorials said never to use CSS as XSLT is the W3C recommended way for styling XML (as if XSLT was a drop-in complete replacement of CSS), so I thought XSLT provided something similar to CSS, as well as the structure changes.

Edit: I don't like to do the transformation server-side. I already can do it without XML/XSLT using the Templating Engine I have built with PHP. I figured if my software became popular enough the XML output it generates would be considered cutting-edge, and I'd wonder how the results would look in Google (with a new mass of all XML websites being indexed). :)
Dec 20 '08 #3
Dormilich
8,658 Expert Mod 8TB
@moltendorf
although you don't use XSLT for transformation, you do it server side too.

just out of interest, what template engine do you use on your XML?
Dec 20 '08 #4
jkmyoung
2,057 Expert 2GB
I've always used xslt to transform my xml data into divs and headers, etc... while pointing to a css sheet to style it. I used XSLT to choose the class of div depending on the elements, but still relied on the CSS to change the look.

Probably a misunderstanding by the people who wrote those tutorials.
Taken from: What is XSL?
Will XSL replace CSS?
No. They are likely to co-exist since they meet different needs. XSL is intended for complex formatting where the content of the document might be displayed in multiple places; for example the text of a heading might also appear in a dynamically generated table of contents. CSS is intended for dynamic formatting of online documents for multiple media; its strictly declarative nature limits its capabilities but also makes it efficient and easy to generate and modify in the content-generation workflow. So they are two different tools; for some tasks, CSS is the appropriate choice and for some tasks, XSL. They can also be used together - use XSL on the server to condense or customize some XML data into a simpler XML document, then use CSS to style it on the client.
Dec 22 '08 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: ted | last post by:
Was wondering if XSLT alone is appropriate for the following situation. From XML, I'm creating a small website (around 50 pages) with pages that link to each other through a nav menu and a...
2
by: Tom Corcoran | last post by:
I am working to ease updating of a html page by transforming 2 xml files. I was going to use xslt for this and had bought 2 unopened books, wrox xslt and o'reilly's xslt cookbook. But am now...
1
by: Mohit | last post by:
Hi Friends I have to call 1 of the 2 child XSLT files from the Main XSLT file based on some criteria. I want one child XSLT file will be executed by version 1 of XSLT processor and the other by...
3
by: Teksure | last post by:
Hi group, searching in the Internet I found two products for XML which incorporate a very robust debugger for XSL/XSLT, I would like you to see these products and then, give me your opinion about...
6
by: Franz Mueller | last post by:
Hi, which of the following books would you recommend: "Dive into Python" or "Beginning Python: From Novice to Professional"? I'm an experienced C++-programmer who wants to take a look at...
5
by: Casey Hawthorne | last post by:
Since there was talk of if-then-else not being allowed in lambda expressions, the following is from "Dive into Python" The and-or conditional expression trick from page 41 of "Dive into Python"...
1
by: Ben Edwards (lists) | last post by:
I have been going through Dive into Python which up to now has been excellent. I am now working through Chapter 9, XML Processing. I am 9 pages in (p182) in the 'Parsing XML section. The...
1
by: Sergey Dubinets | last post by:
In effort to prioritize our goals we composed the list of random features each of them may add value to set of XSLT tools offered from Microsoft. 1. XSLTc (Compiler for XSLT...
3
by: webandwe | last post by:
Hi, Does anyone know where I can get a free scuba dive log book module, I want user to be able login and then the module must display all of their dive. Otherwise how/what do I need to do to...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.