Understanding XSLT transformations: Your Own `XML Transformation Utility` - Testing further with different types of XML
(Page 6 of 6 )
The above samples, which I gave, are quite simple. Let us further extend the same “Hello World” example with different types of XML.
Let us consider the following modifications for the same XML document:
<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="Sample1.xsl"?>
<greeting>
<Hello>Hello, World!</Hello>
</greeting>
If you transform the above XML with same XSL as above, you will still receive the same output (or the same transformation). You should be clear that “.” (dot) refers to the text present in the current node (of the context) along with all the other nodes nested within the same context. That is why, even though “Hello World” is nested in another element, we could still get it out.
For that matter, if you modify the same XML to the following:
<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="Sample1.xsl"?>
<greeting>
Hello, World1!
<Hello>Hello, World2!</Hello>
<Hello>Hello, World3!</Hello>
</greeting>
There is no doubt that you get all the three messages in bold.
Remarks
Even though I used a simple example for XSLT transformation, XSLT has its own depth. I shall now and then contribute articles about XSLT. So, do not forget to check this website frequently. For all of my future articles on XSLT, you can work with the same tool (or utility) I provided along with this article.
The utility that we developed now, is primarily a basic utility for beginners to test their XSLT expertise and is not intended for any production usage. If you have any better ideas for developing the utility, please do not forget to post about them.
The entire demonstration solution has been developed using Visual Studio 2005 Professional Edition on Windows Server 2003 Standard Edition. Note that I didn’t really test the solution on any of the other versions/editions related to the similar suite of Microsoft products.
Any comments, suggestions, ideas, improvements, bugs, errors, feedback etc. are highly appreciated at jag_chat@yahoo.com.
| DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware. |