Biztalk navigation
Generellt | Orkestrering | Mappning | XSLT | Scheman | Pipelines | Annat - Bindings, Adapters..

Saxon-HE
NuGet Gallery | Saxon-HE 10.9.0
.\Tools\Transform.exe "C:\Users\hjm\Desktop\XSLT\cd_catalog.xml" "C:\Users\hjm\Desktop\XSLT\xslt.xslt" -o:test.xml


kolla om ett element finns med i en lista / record (på vänstersidan i biztalk)
<xsl:variable name="found" select="//InputMessagePart_0/s0:GET_SEKRETESSResponse/s0:StoredProcedureResultSet0/s2:StoredProcedureResultSet0/*/text() = $customerPersonNumber"/>

Dubbla conditions
<xsl:for-each select="persons/person[description != 'Polis' and age > 20]">

Filtrera en lista / record
<xsl:for-each select="persons/person[description != 'Polis']">
    <xsl:variable name="var:id" select="userCSharp:strShortTrim(string(id))"/>
    <xsl:variable name="var:fn" select="userCSharp:strShortTrim(string(first_name))"/>
    <xsl:variable name="var:ln" select="userCSharp:strShortTrim(string(last_name))"/>
    <xsl:variable name="var:email" select="userCSharp:strTrim(string(email))"/>
    <xsl:for-each select="key('allCards',id/text())">
        <xsl:variable name="var:v1" select="userCSharp:LogicalExistence(boolean(inhibited))"/>
        <xsl:variable name="var:v3" select="userCSharp:LogicalNot(string($var:v1))"/>
        <record>
            <Efternamn>
                <xsl:value-of select="($var:ln)"/>
            </Efternamn>
        </record>
    </xsl:for-each>
</xsl:for-each>

Ta bort dubbeletter i en for-each (förutsätter att listan är sorterad)
<core:UnitRelations xmlns:core="urn:se:cambio:hsa:user:2">
  <xsl:for-each select="s0:assignments/s0:assignment/s0:unit[not(s0:hsaIdentity=following::s0:hsaIdentity)]">
    <core:UnitRelation>
      <xsl:attribute name="delete">
        <xsl:text>false</xsl:text>
      </xsl:attribute>
      <core:HSAIdentity>
        <xsl:value-of select="./s0:hsaIdentity"/>
        </core:HSAIdentity>
    </core:UnitRelation>
  </xsl:for-each>
</core:UnitRelations>

Ta bort dubbletter i en for-each (Copilot idé, ej testad)
<xsl:stylesheet version="1.0" xmlns:xsl="<http://www.w3.org/1999/XSL/Transform>">
    <xsl:key name="basenhet-by-value" match="Basenhet" use="." />
    <xsl:template match="/units">
        <units>
            <xsl:for-each select="//Basenhet[generate-id() = generate-id(key('basenhet-by-value', .)[1])]">
                <unit>
                    <xsl:attribute name="root">LTB</xsl:attribute>
                    <xsl:if test="fv">
                        <xsl:attribute name="kundnr">
                            <xsl:value-of select="fv/text()"/>
                        </xsl:attribute>
                    </xsl:if>
                </unit>
            </xsl:for-each>
        </units>
    </xsl:template>
</xsl:stylesheet>

    
XSLT 2.0 DateTime
Get datetime now
<xsl:variable name="currentDateTime" select="xs:dateTime(current-dateTime())"/>

XSLT 2.0? group select for BizTalk Map with Script Functoid using Inline XSLT
<xsl:for-each-group select="item" group-by="concat(category, '|', type)">
    <group>
        <category><xsl:value-of select="current-grouping-key()"/></category>
        <items>
            <xsl:for-each select="current-group()">
                <item>
                    <value><xsl:value-of select="value"/></value>
                </item>
            </xsl:for-each>
        </items>
    </group>
</xsl:for-each-group>

XSLT Sortering i en for-each
<xsl:for-each select="Customer">
    <xsl:sort select="attributeValue/text()" data-type="text" order="ascending"/>
    <customer>
        <xsl:attribute name="root">
            <xsl:value-of select="'LTB'"/>
        </xsl:attribute>
    </customer>
</xsl:for-each> 

XSLT variabel från en for-each
<xsl:variable name="a" as="node()*">
  <xsl:for-each-group select="Attestant" group-by="concat(anv/text(), '|', kst/text())">
    <attestant>
        <xsl:attribute name="root">
            <xsl:value-of select="'LTB'"/>
        </xsl:attribute>
        <xsl:attribute name="kundnr">
            <xsl:value-of select="fv/text()"/>
        </xsl:attribute>
    </attestant>
  </xsl:for-each-group>
</xsl:variable>

XSLT Kombinera två variabel och loopa
<xsl:variable name="combined" as="node()*">
  <xsl:copy-of select="$a"/>
  <xsl:copy-of select="$b"/>
</xsl:variable>
<xsl:for-each select="$combined">
    <xsl:sort select="@userid" />
    <attestant>
        <xsl:attribute name="root">
            <xsl:value-of select="'LTB'"/>
        </xsl:attribute>
        <xsl:attribute name="kundnr">
            <xsl:value-of select="@kundnr"/>
        </xsl:attribute>
        <xsl:attribute name="kst">
            <xsl:value-of select="@kst"/>
        </xsl:attribute>
        <xsl:attribute name="userid">
            <xsl:value-of select="@userid"/>
        </xsl:attribute>
        <xsl:attribute name="attest_typ">
            <xsl:value-of select="@attest_typ"/>
        </xsl:attribute>
    </attestant>
</xsl:for-each>