Archive for the ‘XML’ Category

Custom Comments in XML

Friday, 25 September 2009

Imagine you’re using an XML parser to read in files, editing them, and then using an XML formatter to write the files, and that the XML style <!– comments –> are not preserved. If the editing process preserves all elements and attributes, however, even those that are not expected, then that might be exploited to provide custom comments.

Thus, rather than writing this:

<element field="value">
  <!-- comment text -->
</element>

you could write this:

<element field="value">
  <comment>comment text</comment>
</element>

or this:

<element comment="comment text" field="value"/>

Furthermore, note that if the order of sibling elements is not preserved (perhaps the elements are being deliberately sorted), then the comment will have to be a child (not a sibling) of the associated element.

Advertisements

XSLT seems to be broken in Firefox 3…

Friday, 18 September 2009

… but it isn’t really. If you are having this problem, it might just be that the path to the style-sheet is either an absolute path or a relative path upwards.

It might be that Firefox 3 is blocking access outside the current directory. That is a security feature, and as such is worth having. If you can, move the XSLT style-sheet into or below the directory of the XML file using it.

Alternatively, you might opt to disable this security setting, and return to the Firefox 2 behaviour in this respect:

  • type “about:config” into the address bar
  • change the value of “security.fileuri.strict_origin_policy” to “false”

This information is from mozillaZine.

Configurable XML Viewer

Wednesday, 6 May 2009

Suppose that you have an XML file that you wish to examine in detail. You can load that into a browser, and even collapse and expand nodes at will. Here is an XSLT stylesheet that can be used to do something similar, but with custom highlighting.

(more…)

Comparing XML Files

Monday, 20 April 2009

This is just a quick note on comparing XML files.

(more…)

XML Skeletons

Tuesday, 7 April 2009

I often need to write an XML file and can never quite remember the exact syntax. So here, as much for my own record as anything else, are some skeletons.

(more…)