Reputation: 701
I have a few the same files with one little difference. Only difference between this files is declaration in xsl:stylesheet. Example:
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:fn="http://www.w3.org/2005/xpath-functions" xmlns:sf="http://www.company.pl/sf"
xmlns:fo="http://www.w3.org/1999/XSL/Format" exclude-result-prefixes="fo" xmlns:iit="http://www.abc.qwerty.com/scheme/AFQ/DataTypeStructureDef/2018/07/09/InsuranceInThousands" xmlns:is="http://www.abc.qwerty.com/scheme/AFQ/DataTypeStructureDef/2018/07/09/InsuranceStruct">
and in other file I have only difference in iit param
xmlns:iit="http://www.abc.qwerty.com/scheme/AFQ/DataTypeStructureDef/2018/07/09/InsuranceInHundreds"
In effect I have many the same files with this one difference... In other cases I resolve this problem by pass param to my xslt, example:
<xsl:param name="tagCount"/>
but In xsl:stylesheet I don't know If I can pass params and add if condition? How I can reach this effect?
Upvotes: 0
Views: 52
Reputation: 163342
When you're dealing with multiple source documents that have very similar structure but different namespace URIs, I think the best strategy is often to preprocess the source documents so they all use the same namespace URI. That can be done with a simple transformation like this:
<xsl:param name="input-namespace"/>
<xsl:param name="output-namespace"/>
<xsl:template match="*[namespace-uri() = $input-namespace]">
<xsl:element name="name()" namespace-uri="{$output-namespace}">
<xsl:copy-of select="@*"/>
<xsl:apply-templates/>
</xsl:element>
</xsl:template>
Alternatively, write a SAX filter.
Once you've eliminated the namespace differences, the main stylesheet becomes much simpler and less cluttered.
Upvotes: 1