How can I ensure that an element exists in a namespace defined for it
I have a namespace
http://abc.com/interest and I am giving a prefix 'i:'
In my XSL sheet, I am using the above namespace.
Before I display any element values from an XML file,I would first like to
ensure that a particular element exists in my namespace and only after this
will I display an element value
1)InputDocument.xml
Code:
<?xml version="1.0" encoding="UTF-8"?>
<ML>
<Order Acct="MAC" ExDest="ExchDest">
<Hdr Snt="2007-04-05T13:34:47"/>
<Instrmt Issr="Barclays" MMY="200903"/>
</Order>
</ML>
2) Output file format:
Code:
<i:ID>MAC</i:ID>
<i:Issr>Barclays</i:Issr>
<i:Ex>ExchDest</i:Ex>
3) The i:ID,i:Issr element are in the namespace i:.
So,before I display the elements of InputDocument.xml,
I will first check whether each element exists in the namespace 'i:'
and only then display element value of InputDocument.xml
My XSL:
Code:
?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fo="http://www.w3.org/1999/XSL/Format"
xmlns:i="http://www.abc.com/interests:i"
xmlns:fix="http://www.fixprotocol.org/FIXML-4-4">
<xsl:template match="ml:ML">
<xsl:apply-templates select="ml:Order"/>
</xsl:template>
<xsl:template match="fix:Order">
Now,here I need to first ensure that element i:ID is existing in 'i:' and only this is done,I will display the element values:
<i:ID> -- How do I set this element.? I dont want to hard code this?
<xsl:value-of select="@Acct"/>
</i:ID>
</xsl:template>
I hope my query is clear.
Is element validation in the namespace possible?