|
|||||||
New to SitePoint Forums? Register here for free!
|
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
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:
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> Example 3: Line break in XSLT. Code:
<xsl:text> </xsl:text> Code:
<xsl:for-each select="document('products.xml')/catalog/product">
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. |
|
|
|
| Bookmarks |
«
Previous Thread
|
Next Thread
»
| Thread Tools | |
| Display Modes | |
|
|
|
All times are GMT -7. The time now is 03:01.









Threaded Mode