I have a large collection of XML files that I need to convert using XSLT. The problem is that many of these files were written by different people, and they do not use consistent names to refer to schemes. For example, one file may use:
xmlns:itemType="http://example.com/ItemType/XSD"
where another may use the prefix "it" instead of "itemType":
xmlns:it="http://example.com/ItemType/XSD"
If this is not the case, a few files that use one or more synonyms for the same one are enough!
<? xml version = "1.0"?>
<Document
xmlns: it = "http://example.com/ItemType/XSD"
xmlns: itemType = "http://example.com/ItemType/XSD"
xmlns: ItemType = "http://example.com/ItemType/XSD"
...
(obviously there was a lot of cutting and pasting)
Now, since pattern matching in the XSLT file works on the namespace prefix (as opposed to the schema to which this refers), the pattern matches only one of the options. Therefore, if I write something like:
<xsl: template match = "SomeNode [@xsi: type = 'itemType: SomeType']">
...
</ xsl: template>
Then it matches only a subset of the cases in which I want.
Question 1: Is there a way to get XSLT to fit all options?
Question 2: Is there a way to remove duplicates so that all output files use sequential naming?
I naively tried to use "namespace-alias", but I think I misunderstood what it does, because I canβt get it to do anything β either match all the options or affect the XML output.
<? xsl: stylesheet
version = "1.0"
...
xmlns: it = "http://example.com/ItemType/XSD"
xmlns: itemType = "http://example.com/ItemType/XSD"
xmlns: ItemType = "http://example.com/ItemType/XSD"
...
<xsl: output method = "xml" indent = "yes" />
<xsl: namespace-alias stylesheet-prefix = "it" result-prefix = "ItemType" />
<xsl: namespace-alias stylesheet-prefix = "itemType" result-prefix = "ItemType" />