Hi,
In an XSLT template, I'm trying to import an element from an external XML file, and if the element does not exist in the external file, then I add it myself.
What I did was a copy-of(xpath to externale doc), and that works fine. However, after that I do a test to check whether the said element exitsts or not (xsl if "count(element)=0").
And there's the problem, the if seems to always evaluate to true and then I have duplicate elements when the copy-of actually returns something.
Here's the troubling code (XSLT 1.0) :
I'm sure I'm missing something here...
Any suggestion would be more than welcome.
Thanks a lot.
MFR
In an XSLT template, I'm trying to import an element from an external XML file, and if the element does not exist in the external file, then I add it myself.
What I did was a copy-of(xpath to externale doc), and that works fine. However, after that I do a test to check whether the said element exitsts or not (xsl if "count(element)=0").
And there's the problem, the if seems to always evaluate to true and then I have duplicate elements when the copy-of actually returns something.
Here's the troubling code (XSLT 1.0) :
Code:
<xsl:copy-of select="document('TestDoc.xml')//form[@templateref=$formname]/item[@templateref=$itemname]/data"/>
<xsl:if test="count(data)=0">
<xsl:element name="data">
<xsl:element name="possiblevalues00"/>
<xsl:element name="uservalues00"/>
</xsl:element>
</xsl:if>
I'm sure I'm missing something here...
Any suggestion would be more than welcome.
Thanks a lot.
MFR