|
Silicon Tracker Software |
|
|
Hints and Tips on using XML
Editing and Validation
Writing XML is easy. Checking that it correct (well formed and valid) is harder. Here some
hints I picked up from XML Hacks
- The Linux command xmllint can be used for testing that XML is well-formed (xmlint file.xml) and valid (xmllint --valid file.xml). Note xmllint seems to want parameter files to contain a DDDB element
- A good customization for emacs exists : nXML. It checks the XML and
and underlines errors in red (and much more !). Note nXML seems to want parameter files to contain a DDDB element.
Writing XML from C++ and Python
XML can be written from Python and C++ using Genx
Xalan
I installed Xalan and Xerces at CERN (64 bit slc4). To set your enviroment to use:
- setenv TrGroup /afs/cern.ch/lhcb/group/tracking
- setenv XERCESROOT $TrGroup/vol1/mneedham/xerces-c-src_2_7_0
- setenv XALANROOT $TrGroup/vol1/mneedham/xml-xalan/c
- set path=( $path $XERCESROOT/bin)
- set path=( $path $XALANROOT/bin)
- setenv LD_LIBRARY_PATH $XALANROOT/lib:$XERCESROOT/lib
You can use this stylesheet to pretty print your xml
- Xalan -o pretty.xml myxml.xml identity.xsl
Or if you do not want to install xalan use this stylesheet and type
- xsltproc -o pretty.xml pretty.xsl myxml.xml
Note that there will be an error message about not being able to load the
DTD entity. This should not be a problem, since the default DTD is inserted
back by this stylesheet.
xsl allows to do many cool things.
- To strip a tag: < xsl:template match="tag"/ >
Last modified: Thursday 25th 2009f June 2009, 17:26
email: