0

I am studying all that i can about web services such as soap and found some of the xml displayed on some tutorials hard to understand so i decided to learn from the ground up to make sense of things. xml i already understand so then i saw xpath, xslt, xpath,xquery,xlink, xpointer,xml schema, xsl-fo. there are alot of x related stuff that exists in the xml world. i looked into xslt and dont really see any reason to why it would be used in small or big applications. pretty much of what it is doing can be done with css, javascript/jquery or server side. is xslt even being used? or how about DTD,Xpath,Xquery,Xlink,Xpointer,XSL-Fo,Xforms ?

i do know that xml schema is used with soap unless im wrong.

Exploit
  • 6,278
  • 19
  • 70
  • 103

3 Answers3

3

XSLT is a great technology for it's purpose, which is specifically transforming one XML document into another, or sometimes into a plain-text file. If you happen to have data and want to use it to produce HTML or XSL-FO or something else, then XSLT is by far the best way to go. If you're passing XML documents between applications and need to change their format, XSLT is the perfect tool.

However, if your application isn't already using XML, then you probably have no use for it. As a developer, I would recommend learning XSLT because when you do need to do XML transformation it's a great tool to have in your arsenal. In my application we use it in a few places where we have configuration files that get transformed as part of our build process. Besides that though, I haven't used XSLT in years.

XSLT used to be very commonly used on the server to produce HTML. This was particularly the case with traditional ASP back ends largely 'cause traditional ASP was horrible and it was much better to have your business layer produce XML which could then be transformed via XSLT into HTML as opposed to writing ASP code to generate HTML.

Most modern server side environments provide very strong tools for writing dynamic HTML now though so XSLT is less commonly used in this scenario.

As far as comparing XSLT to CSS, there is really no comparison I can see. XSLT is about converting one XML document to another and CSS provides visual styling information for an HTML (or sometimes XML) document.

XPath is very commonly used when working with XML documents and picking out individual pieces of information. It's also heavily used within XSLT.

I've never seen XQuery or XPointer actually used in any of the companies I've worked.

XML Schema is very commonly used for specifying the format of XML documents and validating them. It's heavily used within SOAP Web Services because WSDL utilizes XSD to specify the formats of the SOAP parts.

XSL-FO is for producing PDFs usually. If you want to produce PDFs, this is one way. It technically could be used for other things too, but that's the only use case I'm aware of.

Samuel Neff
  • 73,278
  • 17
  • 138
  • 182
  • whats a good source for learning soap for dummies? what should i learn more of so that soap can make sense to me? – Exploit Apr 01 '11 at 01:18
  • @Sarmen B., you very rarely deal with SOAP directly as a developer. It's almost always abstracted away by the toolset and language. I would recommend using the tools in whatever programming you use to call or implement web services and when you want to know how it's working examine the WSDL, figure out what it all means, and use an HTTP Proxy like Charles or Fiddler to see what is being sent over the wire and figure out what all that means. – Samuel Neff Apr 01 '11 at 02:47
  • i code in php and alot of shipping companies like ups,fedex use soap for web app 2 web app communication. finding already made classes dont always work so i'm stuck with having to know soap and create xml files that can interact with the site. i'm guessing you work with asp/asp.net alot of the tools are already laid out for you. in my case i need to create them. – Exploit Apr 01 '11 at 06:26
  • @Sarmen B., I'm really surprised PHP doesn't have web services support that abstracts away the SOAP. I'm glad to have learned something though, thanks! – Samuel Neff Apr 01 '11 at 11:41
3

i looked into xslt and dont really see any reason to why it would be used in small or big applications. pretty much of what it is doing can be done with css, javascript/jquery or server side.

Well, firstly, most of the people using XSLT are indeed using it server side. Client-side XSLT has never really taken off - for some of the reasons, see my paper at XML Prague 2011 (last week) - the main reason is that it's never been available on EVERY browser. I'm hoping to change the situation with a new product Saxon-CE, but I don't want to turn this into an advertisement.

Secondly, the point about XSLT isn't that it can do things that other technologies can't do, it's that it does what it does much more effectively. If you need to transform XML documents into other XML documents or into HTML, XSLT is by far the most effective way of doing it, once you have got up the learning curve. It's true that with the advent of jQuery, doing this in Javascript isn't quite the nightmare it once was, but the declarative rule-based approach of XSLT has many benefits especially when you have to handle change and variety which always exists in both small and large projects.

Michael Kay
  • 156,231
  • 11
  • 92
  • 164
0

I use XML, XSLT and XQuery as my tools of choice to build websites.

XSLT does what CSS claims to be able to do - separate content from layout.

Say you want to output the HTML for a sales-item;

<div class="salesitem">
   <div class="title">Saucepan</div>
   <a href="images/sp456.jpg">
      <img alt="Saucepan" src="images/sp456.jpg"/>
   </a>
   <div class="price">&#163;19.99</div>
</div>

To output the above using "x" languages, first define the data you want to display. Don't be concerned about layout, appearance or HTML;

<salesitem>
   <title>Saucepan</title>
   <image>sp456.jpg</image>
   <price>19.99</price>
</salesitem>

Then design an XSLT template to turn the above into HTML;

<xsl:template match="salesitem">
   <div class="salesitem">
      <div class="title"><xsl:value-of select="title"/></div>
      <a href="images/{image}">
         <img alt="{title}" src="images/{image}"/>
      </a>
      <div class="price">&#163;<xsl:value-of select="price"/></div>
   </div>
</xsl:template>

Use an XSLT processor to apply the "salesitem" template to the "salesitem" XML and the result will be the HTML you want.

I can't imagine ever going back using response.write ".." or echo ".." to output individual HTML tags. I love the purity of separation that the "x" languages give.

Nigel Alderton
  • 2,265
  • 2
  • 24
  • 55
  • I'm down-voting because this is just awful, especially for April 2011. To build a website, use an MVC framework and CSS and semantic mark-up you can see and modify in the browser. Don't go around telling people to use XSLT to render webpages, its just deplorable. – Luke Puplett Mar 06 '13 at 18:47
  • Why is it deplorable? – Nigel Alderton Mar 08 '13 at 00:10
  • Your answer seems 10 years behind the curve. Going back to response.write? I first dabbled with dynamic web pages in 1997 and even then I never wrote tags directly to the response. XSLT is one of the most disliked 'languages' so to choose it as a view-engine is anti-social and antiquated. – Luke Puplett Mar 11 '13 at 16:25
  • I would have preferred you to answer to the OP's question instead of insulting my answer. Unfortunately this question has been closed. There are many ways to make websites. MVC is not the only answer. – Nigel Alderton Mar 14 '13 at 22:59