Document Map to CAML structure

Home Page Forums BizTalk 2004 – BizTalk 2010 Document Map to CAML structure

Viewing 2 reply threads
  • Author
    Posts
    • #18999

      I  need to construct a xml query based on a collection of items.  The difficulty is the xsd has a repeating reference in its structure.  From XML:

      <?xml version=”1.0″ standalone=”yes”?>
      <AuctionsToExportDS>
        <Auctions>
          <AuctionID>99900</AuctionID>
        <AuctionID>99901</AuctionID>
        <AuctionID>99902</AuctionID>
        <AuctionID>99903</AuctionID>
       </Auctions>
      </AuctionsToExportDS>

      And needs to produce:

      <Where>
        <Or>
          <Eq><FieldRef Name=”AuctionID”>99900</FieldRef></Eq>
          <Or>
            <Eq><FieldRef Name=”AuctionID”>99900</FieldRef></Eq>
            <Or>
               <Eq><FieldRef Name=”AuctionID”>99900</FieldRef></Eq>
               <Eq><FieldRef Name=”AuctionID”>99900</FieldRef></Eq>
            </Or>
           </Or>
         </Or>
      </Where>

      Any ideas on how to do this in a map where the incoming xml document can 1 or more AuctionID elements.  I have the xsds worked out, just don’t know how to write the map or custom xsl.

    • #19211

      Can you post the destination XSD so we can work with you on that?

       Mike

      • #19220

        The XSD being mapped to is for Sharepoint services.  The xsd can be found for a typical installation at: C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\XML.

         For my purposes, I am only concerned with being able to generate a query string containing 1 to an unknown number of Eq statements and Or joins.

         Cheers, Jeff

         For convenience, here is the XSD that covers the Query clause:

          <?xml version=”1.0″ encoding=”utf-16″ ?>
        – <xs:schema xmlns:b=”http://schemas.microsoft.com/BizTalk/2003” xmlns=”http://schemas.microsoft.com/sharepoint/” attributeFormDefault=”unqualified” elementFormDefault=”qualified” targetNamespace=”http://schemas.microsoft.com/sharepoint/” id=”CamlQuery” xmlns:xs=”http://www.w3.org/2001/XMLSchema“>
          <xs:include schemaLocation=”coredefinitions.xsd” id=”CoreDef” />
        – <xs:complexType name=”CamlQueryRoot” mixed=”true”>
        – <xs:all>
          <xs:element minOccurs=”0″ maxOccurs=”1″ name=”Where” type=”LogicalJoinDefinition” />
          <xs:element minOccurs=”0″ maxOccurs=”1″ name=”OrderBy” type=”FieldRefDefinitions” />
          <xs:element minOccurs=”0″ maxOccurs=”1″ name=”Eq” type=”LogicalTestDefinition” />
          <xs:element minOccurs=”0″ maxOccurs=”1″ name=”Field” type=”SimpleFieldRef” />
          <xs:element minOccurs=”0″ maxOccurs=”1″ name=”ListProperty” type=”ListPropertyDefinition” />
          <xs:element minOccurs=”0″ maxOccurs=”1″ name=”LookupColumn” type=”LookupColumnDefinition” />
          <xs:element minOccurs=”0″ maxOccurs=”1″ name=”Column” type=”QueryColumnDefinition” />
          <xs:element minOccurs=”0″ maxOccurs=”1″ name=”GetVar” type=”QueryGetVarDefinition” />
          <xs:element minOccurs=”0″ maxOccurs=”1″ name=”GroupBy” type=”GroupByDefinition” />
          <xs:element minOccurs=”0″ maxOccurs=”1″ name=”Contains” type=”LogicalTestDefinition” />
          <xs:element minOccurs=”0″ maxOccurs=”1″ name=”BeginsWith” type=”LogicalTestDefinition” />
          </xs:all>
          </xs:complexType>
        – <xs:complexType name=”LogicalTestDefinition”>
        – <xs:sequence>
        – <xs:choice minOccurs=”0″ maxOccurs=”unbounded”>
          <xs:element name=”FieldRef” type=”FieldRefDefinition” />
          <xs:element name=”Value” type=”ValueDefinition” />
          <xs:element name=”XML” type=”xs:string” />
          </xs:choice>
          </xs:sequence>
          </xs:complexType>
        – <xs:complexType name=”LogicalJoinDefinition”>
        – <xs:sequence>
        – <xs:choice minOccurs=”0″ maxOccurs=”unbounded”>
          <xs:element name=”Eq” type=”LogicalTestDefinition” />
          <xs:element name=”Geq” type=”LogicalTestDefinition” />
          <xs:element name=”Gt” type=”LogicalTestDefinition” />
          <xs:element name=”Leq” type=”LogicalTestDefinition” />
          <xs:element name=”Lt” type=”LogicalTestDefinition” />
          <xs:element name=”Neq” type=”LogicalTestDefinition” />
          <xs:element name=”And” type=”ExtendedLogicalJoinDefinition” />
          <xs:element name=”Or” type=”ExtendedLogicalJoinDefinition” />
          <xs:element name=”Membership” type=”MembershipDefinition” />
          <xs:element name=”IsNull” type=”LogicalTestDefinition” />
          <xs:element name=”IsNotNull” type=”LogicalTestDefinition” />
          <xs:element name=”DateRangesOverlap” type=”UnlimitedLogicalTestDefinition” />
          <xs:element name=”BeginsWith” type=”LogicalTestDefinition” />
          <xs:element name=”Contains” type=”LogicalTestDefinition” />
          </xs:choice>
          </xs:sequence>
          </xs:complexType>
        – <xs:complexType name=”FieldRefDefinition” mixed=”true”>
        – <xs:simpleContent>
        – <xs:extension base=”xs:string”>
          <xs:attribute name=”Alias” type=”xs:string” />
          <xs:attribute name=”Ascending” type=”TRUEFALSE” />
          <xs:attribute name=”CreateURL” type=”xs:string” />
          <xs:attribute name=”DisplayName” type=”xs:string” />
          <xs:attribute name=”Explicit” type=”TRUEFALSE” />
          <xs:attribute name=”ID” type=”xs:string” />
          <xs:attribute name=”Key” type=”xs:string” />
          <xs:attribute name=”Name” type=”xs:string” />
          <xs:attribute name=”RefType” type=”xs:string” />
          <xs:attribute name=”ShowField” type=”xs:string” />
          <xs:attribute name=”TextOnly” type=”TRUEFALSE” />
          <xs:attribute name=”Type” type=”ReferenceType” />
          </xs:extension>
          </xs:simpleContent>
          </xs:complexType>
        – <xs:simpleType name=”ReferenceType”>
        – <xs:restriction base=”xs:string”>
          <xs:enumeration value=”AVG” />
          <xs:enumeration value=”COUNT” />
          <xs:enumeration value=”MAX” />
          <xs:enumeration value=”MIN” />
          <xs:enumeration value=”SUM” />
          <xs:enumeration value=”STDEV” />
          <xs:enumeration value=”VAR” />
          </xs:restriction>
          </xs:simpleType>
        – <xs:complexType name=”ValueDefinition” mixed=”true”>
        – <xs:complexContent mixed=”true”>
        – <xs:restriction base=”xs:anyType”>
        – <xs:sequence>
        – <xs:choice minOccurs=”0″ maxOccurs=”unbounded”>
          <xs:element minOccurs=”0″ maxOccurs=”1″ name=”Today” type=”xs:string” />
          <xs:element name=”UserID” nillable=”true” type=”xs:string” />
          <xs:element name=”ListProperty” type=”QueryListProperty” />
          <xs:element name=”Now” type=”xs:string” />
          <xs:element name=”Month” type=”xs:string” />
          <xs:element name=”XML” type=”xs:string” />
          </xs:choice>
          </xs:sequence>
          <xs:attribute name=”Type” type=”xs:string” />
          </xs:restriction>
          </xs:complexContent>
          </xs:complexType>
        – <xs:complexType name=”LogicalNullDefinition”>
        – <xs:sequence>
          <xs:element name=”FieldRef” type=”FieldRefDefinition” />
          </xs:sequence>
          </xs:complexType>
        – <xs:complexType name=”ExtendedLogicalJoinDefinition”>
        – <xs:sequence>
        – <xs:choice minOccurs=”0″ maxOccurs=”unbounded”>
          <xs:element name=”Eq” type=”LogicalTestDefinition” />
          <xs:element name=”Geq” type=”LogicalTestDefinition” />
          <xs:element name=”Gt” type=”LogicalTestDefinition” />
          <xs:element name=”Leq” type=”LogicalTestDefinition” />
          <xs:element name=”Lt” type=”LogicalTestDefinition” />
          <xs:element name=”Neq” type=”LogicalTestDefinition” />
          <xs:element name=”And” type=”ExtendedLogicalJoinDefinition” />
          <xs:element name=”Or” type=”ExtendedLogicalJoinDefinition” />
          <xs:element name=”IsNull” type=”LogicalNullDefinition” />
          <xs:element name=”IsNotNull” type=”LogicalNullDefinition” />
          <xs:element name=”DateRangesOverlap” type=”LogicalTestDefinition” />
          <xs:element name=”BeginsWith” type=”LogicalTestDefinition” />
          <xs:element name=”Contains” type=”LogicalTestDefinition” />
          <xs:element name=”Membership” type=”MembershipDefinition” />
          </xs:choice>
          </xs:sequence>
          </xs:complexType>
        – <xs:complexType name=”FieldRefDefinitions” mixed=”true”>
        – <xs:sequence>
          <xs:element minOccurs=”0″ maxOccurs=”unbounded” name=”FieldRef” type=”FieldRefDefinition” />
          </xs:sequence>
          </xs:complexType>
        – <xs:complexType name=”RowDefinition”>
        – <xs:sequence>
          <xs:element minOccurs=”0″ maxOccurs=”unbounded” name=”Field” type=”FieldDataDefinition” />
          </xs:sequence>
          </xs:complexType>
        – <xs:complexType name=”FieldDataDefinition”>
        – <xs:simpleContent>
        – <xs:extension base=”xs:string”>
          <xs:attribute name=”Name” type=”xs:string” />
          </xs:extension>
          </xs:simpleContent>
          </xs:complexType>
        – <xs:complexType name=”RowDefinitions”>
        – <xs:sequence>
          <xs:element minOccurs=”0″ maxOccurs=”unbounded” name=”Row” type=”RowDefinition” />
          </xs:sequence>
          </xs:complexType>
        – <xs:complexType name=”EmptyQueryDefinition”>
          <xs:sequence />
          </xs:complexType>
        – <xs:complexType name=”SimpleFieldRef”>
          <xs:sequence />
          <xs:attribute name=”Name” type=”xs:string” />
          </xs:complexType>
        – <xs:complexType name=”LookupColumnDefinition”>
          <xs:sequence />
          <xs:attribute name=”HTMLEncode” type=”TRUEFALSE” />
          <xs:attribute name=”StripWS” type=”TRUEFALSE” />
          <xs:attribute name=”Name” type=”xs:string” />
          <xs:attribute name=”ShowField” type=”xs:string” />
          <xs:attribute name=”URLEncodeAsURL” type=”TRUEFALSE” />
          </xs:complexType>
        – <xs:complexType name=”QueryColumnDefinition” mixed=”true”>
        – <xs:complexContent mixed=”true”>
        – <xs:extension base=”LookupColumnDefinition”>
          <xs:sequence />
          <xs:attribute name=”Default” type=”xs:string” />
          <xs:attribute name=”URLEncode” type=”TRUEFALSE” />
          </xs:extension>
          </xs:complexContent>
          </xs:complexType>
        – <xs:complexType name=”QueryGetVarDefinition”>
          <xs:sequence />
          <xs:attribute name=”HTMLEncode” type=”TRUEFALSE” />
          <xs:attribute name=”Name” type=”xs:string” />
          </xs:complexType>
        – <xs:complexType name=”QueryListProperty”>
          <xs:sequence />
          <xs:attribute name=”URLEncodeAsURL” type=”TRUEFALSE” />
          <xs:attribute name=”Select” type=”xs:string” />
          </xs:complexType>
        – <xs:complexType name=”MembershipDefinition”>
        – <xs:complexContent mixed=”false”>
        – <xs:extension base=”LogicalTestDefinition”>
          <xs:sequence />
          <xs:attribute name=”Type” type=”xs:string” />
          </xs:extension>
          </xs:complexContent>
          </xs:complexType>
        – <xs:complexType name=”GroupByDefinition”>
        – <xs:complexContent mixed=”false”>
        – <xs:extension base=”LogicalTestDefinition”>
          <xs:sequence />
          <xs:attribute name=”Collapse” type=”TRUEFALSE” />
          </xs:extension>
          </xs:complexContent>
          </xs:complexType>
        – <xs:complexType name=”UnlimitedLogicalTestDefinition”>
        – <xs:sequence>
        – <xs:choice minOccurs=”0″ maxOccurs=”unbounded”>
          <xs:element name=”FieldRef” type=”FieldRefDefinition” />
          <xs:element name=”Value” type=”ValueDefinition” />
          </xs:choice>
          </xs:sequence>
          </xs:complexType>
          </xs:schema>

    • #19226

      Hi Chilberto,

      Looking at your output document, I’m not too sure what determines the structure – i.e. there doesn’t appear to be a pattern in the use of Or or Eq elements. Can you elaborate on this?

      I’ll also second Mike’s comments – if you can post the XSD, that would be helpful.

      Cheers, Nick.

      • #19238

        Sorry to not be clear.  The pattern is to build a collection of 1 to an unknown number of <Eq /> statements with logical <Or /> joins.  This will ultimately be used in a sharepoint lists.asmx GetListItems() method call.  In english terms this will mean that:

        1 elment

        <Eq>

        2 elements

        <Or><Eq /><Eq /><Or />

        3 elements

        <Or><Eq /><Or><Eq /><Eq /><Or /></Or>

        4 elements

        <Or><Eq /><Or><Eq /><Or><Eq /><Eq /><Or /></Or></Or>

        • #19254

          If you wish to achieve the output using a map then you can use the method of recusive template call in xslt.  I was working on this problem and posted the complete code at my blog.  Hope it is useful to you.

          http://prashantbaker.blogspot.com/2008/04/applying-recursion-in-biztalk-maps.html

          I was not able to build the output schema from your post, so used mine.

          I am also putting up the XSLT script below:

          ——————————————–

          <!–  Main Template  –>
            <xsl:template name=”MyXsltTemplate”>
              <xsl:param name=”param2″ />
              <xsl:param name=”param3″ />
              <xsl:element name=”XMLValue”>
               <xsl:call-template name=”Recr”>
                  <xsl:with-param name=”param2″ select=”$param2″/>
                  <xsl:with-param name=”param3″ select=”$param3″/>
                </xsl:call-template>
              </xsl:element>
            </xsl:template>

            <!–  Recursive Template  –>
            <xsl:template name=”Recr”>
              <xsl:param name=”param2″ />
              <xsl:param name=”param3″ />
              <!–  Start of main loop  –>
              <xsl:if test=”$param2 > $param3″>
                <xsl:element name =”Or”>
                  <xsl:element name =”Eq”>
                    <xsl:element name =”FieldRef” >
                      <xsl:attribute name =”Name”>
                          Name
                      </xsl:attribute>
                      <xsl:value-of select =”//AuctionID[$param3]”/>
                    </xsl:element>
                  </xsl:element>
                  <!–  Recusive call only if not the last element  –>
                  <xsl:if test=”$param2 > $param3 +1 ” >
                    <xsl:call-template name=”Recr”>
                      <xsl:with-param name=”param2″ select=”$param2″/>
                      <xsl:with-param name=”param3″ select=”$param3 + 1 “/>
                    </xsl:call-template>
                  </xsl:if>
                  <!–  Only for last element  –>
                  <xsl:if test=”$param2 = $param3 +1 ” >
                    <xsl:element name =”Eq”>
                      <xsl:element name =”FieldRef” >
                        <xsl:attribute name =”Name”>
                          Name
                        </xsl:attribute>
                        <xsl:value-of select =”//AuctionID[$param3+1]”/>
                      </xsl:element>
                    </xsl:element>
                  </xsl:if>
                </xsl:element>
               </xsl:if >
            </xsl:template>
           

           

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