none
Biztalk custom xslt DB Result RRS feed

  • Question

  • Hi!

    I have the following xml:

    <ns0:DBResult xmlns:ns0="http://UpdateCMDB.DBResultCISpecClassstructure">
      <Result>
        <Record>
          <ColumnValue>15</ColumnValue>
          <ColumnName>Cis</ColumnName>
        </Record>
        <Record>
          <ColumnValue>K040105</ColumnValue>
          <ColumnName>ClassficationID</ColumnName>
        </Record>
      </Result>
      <Result>
        <Record>
          <ColumnValue>12</ColumnValue>
          <ColumnName>Cis</ColumnName>
        </Record>
        <Record>
          <ColumnValue>K040301</ColumnValue>
          <ColumnName>ClassficationID</ColumnName>
        </Record>
      </Result>
    </ns0:DBResult>

    and i want to transform it to:

    <ns1:Log xmlns:ns1="http://UpdateCMDB.CILog">
        <Klassifikationen>
            <Klassifikation>
                <Name>K040105</Name>
                <AnzahlCMDB>15</AnzahlCMDB>
            </Klassifikation>
            <Klassifikation>
                <Name>K040301</Name>
                <AnzahlCMDB>12</AnzahlCMDB>
            </Klassifikation>
        </Klassifikationen>
    </ns1:Log>

    can anyone help me to do this per custom xslt?

    Monday, June 11, 2012 1:40 PM

Answers

All replies

  • It may help you http://code.msdn.microsoft.com/windowsdesktop/Muenchian-Grouping-and-790347d2

    Christophe BRANDO...If this answers your question, please Mark as the Answer. If this post is helpful, please vote as helpful.

    Monday, June 11, 2012 2:00 PM
  • thanks,

    but i have no key value. So i can't group.

    Tuesday, June 12, 2012 10:31 AM
  • <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
        xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl ns0"
                    xmlns:ns0="http://UpdateCMDB.DBResultCISpecClassstructure" xmlns:ns1="http://UpdateCMDB.CILog">
      <xsl:output method="xml" indent="yes"/>  
      <xsl:template match="/ns0:DBResult">
        <ns1:Log >
          <Klassifikationen>
          <xsl:for-each select="Result">
            <Klassifikation>
              <xsl:for-each select="Record[2]">
                <Name>
                  <xsl:value-of select="ColumnValue"/>
                </Name>
              </xsl:for-each>
              <AnzahlCMDB>
                <xsl:value-of select="Record/ColumnValue"/>
              </AnzahlCMDB>         
            </Klassifikation>
          </xsl:for-each>
          </Klassifikationen>
        </ns1:Log>
      </xsl:template>
    </xsl:stylesheet>


    KiranMP


    • Edited by Kiran molala Tuesday, June 12, 2012 11:16 AM exclude
    • Proposed as answer by Kiran molala Tuesday, June 12, 2012 11:24 AM
    Tuesday, June 12, 2012 11:13 AM
  • Thank you very much :-)
    • Marked as answer by nick_1810 Tuesday, June 12, 2012 11:23 AM
    Tuesday, June 12, 2012 11:23 AM
  • Hey Nick,

    Use this XSL for ur transformation...This removes the hard coding of the element position and will work even if the order of the Record group changes...

    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"

        xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl ns0"

                    xmlns:ns0="http://UpdateCMDB.DBResultCISpecClassstructure" xmlns:ns1="http://UpdateCMDB.CILog">

      <xsl:output method="xml" indent="yes"/>

      <xsl:template match="/ns0:DBResult">

        <ns1:Log >

          <Klassifikationen>

            <xsl:for-each select="Result">

              <Klassifikation>

                <xsl:for-each select="Record[ColumnName/text()='ClassficationID']">

                  <Name>

                    <xsl:value-of select="ColumnValue"/>

                  </Name>

                </xsl:for-each>

                <AnzahlCMDB>

                  <xsl:value-of select="Record[ColumnName/text()='Cis']/ColumnValue"/>

                </AnzahlCMDB>

              </Klassifikation>

            </xsl:for-each>

          </Klassifikationen>

        </ns1:Log>

      </xsl:template>

    </xsl:stylesheet>


    Regards Ritu Raj Dont forget : - When you see answers and helpful posts, please click Vote As Helpful, Propose As Answer, and/or Mark As Answer


    Tuesday, June 12, 2012 11:34 AM
    Answerer