Exclude ns0 prefix from elements

Home Page › Forums › BizTalk 2004 – BizTalk 2010 › Exclude ns0 prefix from elements

Viewing 1 reply thread
  • Author
    Posts
    • #22223

      Hi,

      Firstly this is my first post, so go easy if its not very clear, and Im creating duplicate posts 🙂

      Ok Basicly I have a single orchestration consuming an incoming message. (type A) Then using a map transform this to an outing message (Type B) However the output of Message B includes the prefix ns0 in front of all my elements and attriibutes. The problem is the external service who will be consuming this message do not proces/or validate any xml messages that include prefixes. So to get around this problem I wrote a single transform that removes all prefixes from both elements and prefixes. However the schema for message B, defines an attribute called Type, this can be of 2 types VGIS or LID. If i am correct xml also uses type (but with a lowercase type) to describe the type of the elemnts (string, int etc, etc). one way around this was to add xsi:type manualy, but since i am using a map im not sure if this can be done. Is there any way of modifying my transform to exclude all prefixes except reserved ones such as xsi?

      the transform i am using is

       

      <xsl:stylesheet xmlns:xsl=”http://www.w3.org/1999/XSL/Transform&#8221; version=”1.0″>
        <xsl:template name=”removePrefixFromAttribute”>
          <xsl:param name=”attribute”/>
          <xsl:param name=”prefix”/>
          <xsl:choose>
            <xsl:when test=”contains($attribute,$prefix)”>
              <xsl:value-of select=”substring-before($attribute,$prefix)”/>
              <xsl:value-of select=”””/>
              <xsl:call-template name=”removePrefixFromAttribute”>
                <xsl:with-param name=”attribute” select=”substring-after($attribute, $prefix)”/>
                <xsl:with-param name=”prefix” select=”$prefix”/>
              </xsl:call-template>
            </xsl:when>
            <xsl:otherwise>
              <xsl:value-of select=”$attribute”/>
            </xsl:otherwise>
          </xsl:choose>
        </xsl:template>

        <xsl:template match=”*”>
          <xsl:element name=”{local-name()}” namespace=”{namespace-uri()}”>
            <xsl:apply-templates select=”@*|node()”/>
          </xsl:element>
        </xsl:template>
        <xsl:template match=”@*”>
          <xsl:variable name=”noPrefix”>
            <xsl:call-template name=”removePrefixFromAttribute”>
              <xsl:with-param name=”attribute” select=”.”/>
              <xsl:with-param name=”prefix” select=”‘ns0:'”/>
            </xsl:call-template>
          </xsl:variable>
          <xsl:attribute name=”{local-name()}”>
            <xsl:value-of select=”$noPrefix”/>
          </xsl:attribute>
        </xsl:template>
        <xsl:template match=”processing-instruction()|comment()”>
          <xsl:copy>
            <xsl:apply-templates select=”node()”/>
          </xsl:copy>
        </xsl:template>
      </xsl:stylesheet>

    • #22225

      Is it possible to see  the schema for TypeB message and an example of the correct output?
      You can use email: greg.forsythe at gmail.com if they are too large

      • #22226

        I cant send you the schema but I can send you an instance of the output file. Will this be enough?

Viewing 1 reply thread
  • The forum ‘BizTalk 2004 – BizTalk 2010’ is closed to new topics and replies.