Results 1 to 1 of 1

Thread: xquery

  1. #1
    Join Date
    Jul 2006
    Posts
    111

    Unanswered: (please delete this post, thanks)

    Hi I need some help, I tried a few xquery but couldn't get it exactly the way I want it. What would be the xquery way of doing the following such that at the end of the operation I would like to have the following value:

    (Many thanks in advance)
    (ps. is there a more elegant way of doing this? i am avoiding a string replace)

    Code:
    @rootXml = '<InterimMetadata xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns=""http://schemas.edcdata.net/grouper/InterimMetadata.xsd">
      <IsTentative>false</IsTentative>
      <IsDeleted>true</IsDeleted>
      <IsCalculated>true</IsCalculated>
      <Templates>
        <Template>
          <Name>One</Name>
          <Guid>{1DB34403-E1CC-47A3-B6BB-6C14073C6425}</Guid>
          <Description>Phase HS2-41</Description>
          <Configs>
            <Config>
              <LinkSerial>2345327236</LinkSerial>
              <Description>Booster up</Description>
            </Config>
            <Config>
              <LinkSerial>63465424562</LinkSerial>
              <Description>Booster Horz</Description>
            </Config>
          </Configs>
        </Template>
        <Template>
          <Name>Three</Name>
          <Guid>{966ECA46-4D9C-4960-8DA7-A57AD08F8C66}</Guid>
          <Description>Phase MX2-2Z</Description>
          <Configs>
            <Config>
              <LinkSerial>4573384573</LinkSerial>
              <Description>Booster Z</Description>
            </Config>
            <Config>
              <LinkSerial>2345427898</LinkSerial>
              <Description>Booster Down</Description>
            </Config>
          </Configs>
        </Template>
      </Templates>
    </InterimMetadata>'
    From the following:


    Code:
    declare @rootXml xml
    declare @template1 xml
    declare @template2 xml
    
    declare @isTentative bit set @isTentative = 0
    declare @isDeleted bit set @isDeleted = 1
    declare @isCalculated bit set @isCalculated = 1
    
    set @rootXml =
    '<InterimMetadata xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.edcdata.net/grouper/InterimMetadata.xsd">
      <IsTentative>true</IsTentative>
      <IsDeleted>true</IsDeleted>
      <IsCalculated>false</IsCalculated>
      <Templates>
      </Templates>
    </InterimMetadata>'
    
    set @template1 = '<Template>
      <Name>One</Name>
      <Guid>{1DB34403-E1CC-47A3-B6BB-6C14073C6425}</Guid>
      <Description>Phase HS2-41</Description>
      <Configs>
        <Config>
          <LinkSerial>2345327236</LinkSerial>
          <Description>Booster up</Description>
        </Config>
        <Config>
          <LinkSerial>63465424562</LinkSerial>
          <Description>Booster Horz</Description>
        </Config>
      </Configs>
    </Template>'
    
    
    set @template2 = '<Template>
      <Name>Three</Name>
      <Guid>{966ECA46-4D9C-4960-8DA7-A57AD08F8C66}</Guid>
      <Description>Phase MX2-2Z</Description>
      <Configs>
        <Config>
          <LinkSerial>4573384573</LinkSerial>
          <Description>Booster Z</Description>
        </Config>
        <Config>
          <LinkSerial>2345427898</LinkSerial>
          <Description>Booster Down</Description>
        </Config>
      </Configs>
    </Template>'
    Last edited by g11DB; 05-07-12 at 08:49. Reason: (please delete this post, thanks)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •