This question is not about XML syntax validation but about the processing of. My question is can i add nodes wihout breaking the file? Assumit of course the person who imports the file obeys all standards and rules.
Maby this is unclear so let me provide an example:
I have an XML file that holds somd data.
desiredformat:
<item>
<name>somename</name>
<description>somedescription</description>
<contents>
<somecontent1>bla</somecontent1>
<somecontent2>bla2</somecontent2>
</contents>
</item>
Now I want to modify the file like so:
<item>
<name>somename</name>
<description>somedescription</description>
<contents>
<somecontent1>bla</somecontent1>
<somecontent2>bla2</somecontent2>
</contents>
<myNewCustomAttribute>
<someNode>
<whatever/>
</someNode>
</myNewCustomAttribute>
</item>
The reason is that I convert XML files from one format to another so that they can be imported in a system. I would like to create one additional node where i store the source xml file, so i don't loose the original data and can spot errors later and stuff...
So like in object oriented subtyping (the subtype always fullfills the requirements of the parent type and can be used 开发者_如何学JAVAas one).
Is this a - or is there another - possible way to extend xml files so that they stay intact for their original purpose? What are the rules for that?
It depends on the application that processes the XML file. If it uses relax ng, DTD, XSD to validate that XML, you should look the schema to see what is allowed, what is not. If there is no schema, it completely depends on the processing algorithm. It is OK, if it succeeds.
精彩评论