Go Back   SitePoint Forums > Forum Index > Program Your Site > XML and Web Services
Newsletter FAQ Members List Calendar Mark Forums Read

New to SitePoint Forums? Register here for free!

SitePoint Sponsor
 
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Old Nov 26, 2007, 08:23   #1
kgun
SitePoint Addict
 
Join Date: Nov 2005
Location: Moss, Norway.
Posts: 280
XML Minimalism.

The XML family of technologies is very rich. In addition there are different parsers in different languages like PHP. It is fairly easy to start XML tagging if you are used to HTML tagging. Some other XML technologies like XML Schema and XSLT also use XML tags with name spaces. So it is very important to understand namespaces. If you are used to PHP, it is sometimes tempting to use PHP XML parsers and DOM to have the job done. But remember, you can do a lot of things only by using XSLT. And you can define your grammar by using XML Schema. So before you use a scripting solution, you should see if it is possible to have the job done in e.g. XSLT. That have some advantages:
  1. Robustness. A solution within the family should be most robust.
  2. Simplicity. Make it simple, as simple as possible, but no simpler.
  3. Last but not least, minimalism.

Some useful hints:

Example 1: Use xml:space to handle white space. Valid values are preserve and default.

Example 2: Write your own XML Schema to handle white space.

Code:
<?xml version="1.0?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:element name="myElement">
<xsd:simpleType>
<xsd:restriction base="xsd:string">
<xsd:whiteSpace value="collapse" />
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
</xsd:schema>
Valid values are preserve, replace and collapse.

Example 3: Line break in XSLT.
Code:
<xsl:text>
</xsl:text>
Example 4: The XSL document function.
Code:
<xsl:for-each select="document('products.xml')/catalog/product">
My personal priority of learning XML.
  1. XML tagging.
  2. XPath
  3. XPointer and XInclude.
  4. Name spaces in XML.
  5. XSL(T) and XSL-FO
  6. XML Schema
  7. XLink
  8. Other XML technologies
XML tutorials.

Conclusion and advice:
If you find a simple solution within the XML member family, use that before you use a scripting / programming solution.

Last edited by kgun; Nov 26, 2007 at 08:59.
kgun is offline   Reply With Quote
 

Bookmarks

« Previous Thread | Next Thread »

Thread Tools
Display Modes

 
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Sponsored Links
 
Forum Jump


All times are GMT -7. The time now is 03:01.


Powered by vBulletin® Version 3.7.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Copyright 1998-2009, SitePoint Pty Ltd. All Rights Reserved