Thursday, May 19, 2011

How to add a attribute of XML as a html element attribute using XSLT

Once you work with XSLT you may come across a situation where you need to directly apply a value of a XML attribute as the value of a HTML attribute.There are two options to figure the things out.

myXML.xml










Target html










In the above case the value of the attribute boxSize is directly applied as the value of the attribute size of input element in HTML format.This can be achieved as below two methods.

method 1











method 2




As you see method 2 is more easy and it is the simple way to get the job done.Thank you.Hope this helps.

Wednesday, May 11, 2011

How to choose a XML parser

There are many XML parsers out there.So here I am going to give some pros and cons of those.SAX,StAX,DOM,JAXB are the XML parsers that I took into consideration.

Parsing Mechanism

Features

JAXB

High memory usage

DOM

High memory usage

StAX

XML schema can not be validated.
Low memory usage

SAX

XML schema can be validated
Low memory usage

Hope this will give you some hints about what to choose.Thank you.