0

I have a few such namespace definitions in every xml file :-

xmlns:xi="http://www.w3.org/2001/XInclude" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
etc etc

Is there a way for me to specify these as defaults so that I don't have to write this in each and every XML file?

If it helps, I am primarily using xerces-c for parsing but I'd prefer a library independent solution.

owagh
  • 3,428
  • 2
  • 31
  • 53

1 Answers1

0

@owagh, instead of writing the XML file from scratch each time, have you considered defining an XML template that contains all of the applicable namespaces? Your program can then start by first loading that XML template and then begin populating it.

DavidRR
  • 18,291
  • 25
  • 109
  • 191
  • well i was hoping more to save space while transmitting the xml file... The way I'm doing it right now is to store an XSL template at the client side just to add these to the root element and copy the rest of the document but I'd like to avoid using an extra technology (and have an extra dependency) if possible. Is there a better way? – owagh Aug 20 '12 at 22:24
  • Perhaps you can explain why saving a few bytes of space is so critical. What is the overall size of the typical document you are transmitting and how many bytes do the namespace prefix declarations add? – DavidRR Aug 21 '12 at 11:57
  • Well the size of the typical file being transmitted is reduced by ~5-10% by removing the prefix declarations. Anyways, would make more sense to compress it and send... – owagh Sep 04 '12 at 21:45