Home Page › Forums › BizTalk 2004 – BizTalk 2010 › deleting -1 on mapping › deleting -1 on mapping
Forgot about blank nodes.
i.e. <Record type=\”27\”/>
[code:1:49afc212aa] <xsl:stylesheet xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\" xmlns:msxsl=\"urn:schemas-microsoft-com:xslt\" xmlns:var=\"http://schemas.microsoft.com/BizTalk/2003/var\" exclude-result-prefixes=\"msxsl var\" version=\"1.0\">
<xsl:output omit-xml-declaration=\"yes\" method=\"xml\" version=\"1.0\" />
<xsl:template match=\"/\">
<xsl:call-template name=\"recursive\"/>
</xsl:template>
<xsl:template name=\"recursive\">
<xsl:for-each select=\"attribute::*\">
<xsl:variable name=\"var:a1\" select=\"local-name()\"/>
<xsl:attribute name=\"{$var:a1}\">
<xsl:value-of select=\".\"/>
</xsl:attribute>
</xsl:for-each>
<xsl:for-each select=\"child::*\">
<xsl:variable name=\"var:name\" select=\"local-name()\"/>
<xsl:variable name=\"var:ns\" select=\"namespace-uri()\"/>
<xsl:choose>
<xsl:when test=\"count(child::*) > 0\">
<xsl:element namespace=\"{$var:ns}\" name=\"{$var:name}\">
<xsl:call-template name=\"recursive\"/>
</xsl:element>
</xsl:when>
<xsl:otherwise>
<xsl:if test=\"(text() != ‘-1’) or (string-length(text()) = 0)\">
<xsl:element namespace=\"{$var:ns}\" name=\"{$var:name}\">
<xsl:for-each select=\"attribute::*\">
<xsl:variable name=\"var:a1\" select=\"local-name()\"/>
<xsl:attribute name=\"{$var:a1}\">
<xsl:value-of select=\".\"/>
</xsl:attribute>
</xsl:for-each>
<xsl:value-of select=\".\"/>
</xsl:element>
</xsl:if>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>[/code:1:49afc212aa]