Question was changed, which I believe is different from the existing one that is considered to be similar.
I have a property file specify the mapping between old namespace and new namespace. For example: http://old-namespace1 = http://new-namespace1. The mapping is 1:1. There are about two hundred entries. I can build a map for old namespace and new namespace with this mapping property file.
For each xml file that needs such changes, I want to replace all occurrences of old namespace uri in the mapping file with the corresponding new namespace uri.
The following is a sample of xml file before the change and after the change.
xml file before:
<?xml version="1.0" encoding="UTF-8" ?>
<rootElem xmlns="http://old-namespace1" xmlns:ns2="http://old-namespace2" xmlns:ns3="http://old-namespace3">
<childElem xmlns="http://old-namespace4">
...
</childElem>
...
</rootElem>
xml file after:
<?xml version="1.0" encoding="UTF-8" ?>
<rootElem xmlns="http://new-namespace1" xmlns:ns2="http://new-namespace2" xmlns:ns3="http://new-namespace3">
<childElem xmlns="http://new-namespace4">
...
</childElem>
...
</rootElem>
I'd like to do it using xslt and call the transform from java program: 1. for each xmlns:*, get its value 2. find if the value has mapping, if so, get the mapped new value, 3. output the new value.
My question is for #2 above: I can list the maps in xsl. But if the map already exists in another file, is there a way in xsl to read the file and get the map?