none
Biztalk Map Inline XSLT Namepace Question

    Question

  • People,

    When we reference the fields from source schema in the xslt script, how should we deal with those fields with namespace? Do we have to hard code these namespaces in the xslt? Any suggestions?
    Thanks
    Wednesday, July 22, 2009 3:48 AM

Answers

  • Basically, in orer for a map to function correctly with a given inut schemas, you need to assume that the namespace doesn't change, and therefore, hardcoding it is ok.

    the mapper helps you out a ltitle bit, as it per default does not use namespaces for its links, so if the namespace of a schema changes, then the correct namespace is just inserted in the XSLT script at compile-time.

    But in short; Ye,s you can assume the namespace is constant. If you validate a map and check out the generated XSLT, you will see, that the mapper generated XSLT that does not use the namespace in all links, but instead defines a prefix (s0, s1, s2, and so on) for the namespaces, to make the XPath expressions more easily read.


    eliasen, representing himself and not the company he works for.
    Three times MVP and three times MCTS in BizTalk.
    Blog: http://blog.eliasen.dk
    Wednesday, July 22, 2009 1:05 PM

All replies

  • I prefer to copy XPath for the nodes without changing, with namespaces. For example:

    <xsl:element name ="ns0:PersonBirthDate">
    <xsl:variable name="Var1" select="/*[local-name()='PersRequest' and namespace-uri()='http://myNS/Pers/1.0']/*[local-name()='PersonBirthDate' and namespace-uri()='http://Standard1']/*[local-name()='Date' and namespace-uri()='Standard1']" />
    <xsl:value-of select="normalize-space($Var1)" />
    </xsl:element>

    Usually prefix the "ns0" is "stable" and I don't need to use the namespace.
    Leonid Ganeline [BizTalk MVP] http://geekswithblogs.net/leonidganeline
    • Proposed as answer by Terry Hanley Monday, April 30, 2012 2:21 PM
    • Unproposed as answer by Terry Hanley Monday, April 30, 2012 2:21 PM
    Wednesday, July 22, 2009 4:39 AM
  • Basically, in orer for a map to function correctly with a given inut schemas, you need to assume that the namespace doesn't change, and therefore, hardcoding it is ok.

    the mapper helps you out a ltitle bit, as it per default does not use namespaces for its links, so if the namespace of a schema changes, then the correct namespace is just inserted in the XSLT script at compile-time.

    But in short; Ye,s you can assume the namespace is constant. If you validate a map and check out the generated XSLT, you will see, that the mapper generated XSLT that does not use the namespace in all links, but instead defines a prefix (s0, s1, s2, and so on) for the namespaces, to make the XPath expressions more easily read.


    eliasen, representing himself and not the company he works for.
    Three times MVP and three times MCTS in BizTalk.
    Blog: http://blog.eliasen.dk
    Wednesday, July 22, 2009 1:05 PM