HomeHomeDiscussionsDiscussionsAuthor-it Devel...Author-it Devel...Exported XML and API SaveXML functionExported XML and API SaveXML function
Previous
 
Next
New Post
2/16/2012 7:14 AM
 

I want to take the xml generated by the AIT desktop client's "Manage-->Save Objects as XML" function, and restore the objects it contains by submitting the exported xml back to the API's objectCommon service SaveXml function.  When I do this, the API SaveXml function creates new AIT folders containing the exported objects.  But, often some of these new AIT folders are placed at the wrong levels of the AIT folder hierarchy.

So, I'm writing a tool that will take a windows hierarchy of folders and recreate the same hierarchy of folders in an AIT library using the folder service.  I will place each exported XML file for a particular AIT folder in its corresponding windows folder.  When the tool walks the windows folders to create AIT folders, it will submit each XML file it finds to the API's SaveXML function with its create new folder parameter set to false to generate objects for the corresponding AIT folder.

I've noticed that each export XML file contains objects with FolderID tags that map to a Folders section with Folder tags.  Each folder tag has a ParentFolderID tag that maps to another folder tag. This mapping goes all the way down until a folder with ParentFolderID=0 is reached.  It looks like the IDs and Folder subtags have to be remapped before I can call SaveXML to import any objects.  I have the ID of the AIT folder that will act as the container for the imported objects, as I've already created it through the API.

The remapping in the xml begins by changing the FolderID tags for each object to the ID of the current AIT folder the objects will reside in.  As all objects were originally exported from the same AIT folder, they will all contain the same folderID value. 

I then use the original folderID value to locate the folder tag in the XML that represents it.  I retrieve the new AIT folder through the API and use its values to substitute the ones in the xml for the folder.  I then search for the next old parentfolderID and do the same for the folder tag I find.  This is repeated until there are no more folder tags left.

But, when I submit this xml to the API using  SaveXML(xml,false,true) The objects aren't recreated anywhere.  It looks like I'm missing something else that needs to be remapped inside the xml.  What else is there that needs to be done?

I've checked the folder remappings, and they match to the actual folders in the target AIT library. The changes I have made are delineated with asterisks in the first column.  I want the objects in the XML file to reside in a similar AIT folder hierarchy which has different folderIDs than the source AIT hierarchy had:

<AuthorIT version="5.5.1" xmlns="http://www.authorit.com/xml/authorit" xmlns:xsi="http://www.w3.org/2001/XMLSchema-inst...">
  <Objects>
    <Book>
      <Object>
        <BasedOn>0</BasedOn>
        <CreatedBy>(supervisor)</CreatedBy>
        <CreatedDate>2012-02-14T15:02:04</CreatedDate>
        <Description>BOOKA2 1</Description>
 ***       <FolderID>188</FolderID>
        <GUID>67331884ad75498db973b53c97027265</GUID>
        <ID>4237</ID>
        <IncludeInHelp>true</IncludeInHelp>
        <IncludeInPrint>true</IncludeInPrint>
        <IncludeInWeb>true</IncludeInWeb>
        <IsTemplate>false</IsTemplate>
        <Key>4237</Key>
        <LocalizationID>0</LocalizationID>
        <ModifiedID>12816</ModifiedID>
        <ModifiedBy>(supervisor)</ModifiedBy>
        <ModifiedDate>2012-02-14T15:06:28</ModifiedDate>
        <ReleaseStateID>0</ReleaseStateID>
        <Status>1</Status>
        <Type>Book</Type>
        <Version>1</Version>
        <VariantParentID>0</VariantParentID>
        <LocID>0</LocID>
        <ModifiedComments></ModifiedComments>
      </Object>
      <ContentsNodes>
        <Node id="4241"></Node>
        <Node id="4242"></Node>
      </ContentsNodes>
      <VariableAssignments>
        <VariableAssignment>
          <ID>29</ID>
          <Name>HISTCOMMENT</Name>
          <Value></Value>
          <ValueObject>0</ValueObject>
          <Style>0</Style>
          <PublishPrompt>false</PublishPrompt>
        </VariableAssignment>
      </VariableAssignments>
      <PrintByLine></PrintByLine>
      <PrintTitle>BOOKA2 1</PrintTitle>
      <PrintSubTitle></PrintSubTitle>
      <PrintSuperTitle></PrintSuperTitle>
      <PrintVersion></PrintVersion>
      <PrintWordTemplate></PrintWordTemplate>
      <HelpAltPrefix></HelpAltPrefix>
      <HelpCitation></HelpCitation>
      <HelpCompression>0</HelpCompression>
      <HelpCopyright></HelpCopyright>
      <HelpFileName>BOOKA2 1</HelpFileName>
      <HelpIncludeFile></HelpIncludeFile>
      <HelpMacro>0</HelpMacro>
      <HelpTitle>BOOKA2 1</HelpTitle>
      <HelpTopicOffset>0</HelpTopicOffset>
      <WebAdditionalFiles />
      <WebBaseFontSize>12</WebBaseFontSize>
      <WebBaseURL></WebBaseURL>
      <WebByLine></WebByLine>
      <WebFramesetTemplate></WebFramesetTemplate>
      <WebSuperTitle></WebSuperTitle>
      <WebTitle>BOOKA2 1</WebTitle>
      <WebVersion></WebVersion>
    </Book>
    <Book>
      <Object>
        <BasedOn>0</BasedOn>
        <CreatedBy>(supervisor)</CreatedBy>
        <CreatedDate>2012-02-14T15:02:33</CreatedDate>
        <Description>BOOKA2 2</Description>
***        <FolderID>188</FolderID>
        <GUID>b047c7c424d4402983736d800b952dc6</GUID>
        <ID>4238</ID>
        <IncludeInHelp>true</IncludeInHelp>
        <IncludeInPrint>true</IncludeInPrint>
        <IncludeInWeb>true</IncludeInWeb>
        <IsTemplate>false</IsTemplate>
        <Key>4238</Key>
        <LocalizationID>0</LocalizationID>
        <ModifiedID>12811</ModifiedID>
        <ModifiedBy>(supervisor)</ModifiedBy>
        <ModifiedDate>2012-02-14T15:02:33</ModifiedDate>
        <ReleaseStateID>0</ReleaseStateID>
        <Status>1</Status>
        <Type>Book</Type>
        <Version>1</Version>
        <VariantParentID>0</VariantParentID>
        <LocID>0</LocID>
        <ModifiedComments></ModifiedComments>
      </Object>
      <ContentsNodes></ContentsNodes>
      <VariableAssignments>
        <VariableAssignment>
          <ID>29</ID>
          <Name>HISTCOMMENT</Name>
          <Value></Value>
          <ValueObject>0</ValueObject>
          <Style>0</Style>
          <PublishPrompt>false</PublishPrompt>
        </VariableAssignment>
      </VariableAssignments>
      <PrintByLine></PrintByLine>
      <PrintTitle>BOOKA2 2</PrintTitle>
      <PrintSubTitle></PrintSubTitle>
      <PrintSuperTitle></PrintSuperTitle>
      <PrintVersion></PrintVersion>
      <PrintWordTemplate></PrintWordTemplate>
      <HelpAltPrefix></HelpAltPrefix>
      <HelpCitation></HelpCitation>
      <HelpCompression>0</HelpCompression>
      <HelpCopyright></HelpCopyright>
      <HelpFileName>BOOKA2 2</HelpFileName>
      <HelpIncludeFile></HelpIncludeFile>
      <HelpMacro>0</HelpMacro>
      <HelpTitle>BOOKA2 2</HelpTitle>
      <HelpTopicOffset>0</HelpTopicOffset>
      <WebAdditionalFiles />
      <WebBaseFontSize>12</WebBaseFontSize>
      <WebBaseURL></WebBaseURL>
      <WebByLine></WebByLine>
      <WebFramesetTemplate></WebFramesetTemplate>
      <WebSuperTitle></WebSuperTitle>
      <WebTitle>BOOKA2 2</WebTitle>
      <WebVersion></WebVersion>
    </Book>
  </Objects>
  <ObjectSummarys>
    <ObjectSummary>
      <ID>4241</ID>
      <Type>Topic</Type>
      <GUID>96af97c16acc4b048741a3ad4ca8c4e3</GUID>
      <Description>TOPICB1 1</Description>
    </ObjectSummary>
    <ObjectSummary>
      <ID>4242</ID>
      <Type>Topic</Type>
      <GUID>e30a1c75b05146b18e615e038d587528</GUID>
      <Description>TOPICB1 2</Description>
    </ObjectSummary>
  </ObjectSummarys>
  <Folders>
    <Folder>
***     <ID>188</ID>
***      <Name>A2</Name>
***      <GUID>1ee01848-eeda-4f56-a67c-c9f845edec4a</GUID>
***      <ParentFolderID>187</ParentFolderID>
***      <HasSubFolders>false</HasSubFolders>
    </Folder>
    <Folder>
***      <ID>187</ID>
***      <Name>A1</Name>
***      <GUID>dd65769e-3c12-4878-b6f1-07d22625f297</GUID>
***      <ParentFolderID>186</ParentFolderID>
***      <HasSubFolders>true</HasSubFolders>
    </Folder>
    <Folder>
***      <ID>186</ID>
***      <Name>Junk</Name>
***      <GUID>fdddcbc4-fc2d-424c-9d69-3e69f839208c</GUID>
***      <ParentFolderID>0</ParentFolderID>
***      <HasSubFolders>true</HasSubFolders>
    </Folder>
  </Folders>
  <ReleaseStates>
    <ReleaseState>
      <ID>4</ID>
      <Name>Book Review</Name>
      <GUID>E6F61AD3C7F74D28A614826BF545FCF6</GUID>
      <Color>16777215</Color>
      <ReviewColor>0</ReviewColor>
      <Type>0</Type>
    </ReleaseState>
    <ReleaseState>
      <ID>1</ID>
      <Name>Draft</Name>
      <GUID>D9E1C8D4F3584BF392A13F2A392C0029</GUID>
      <Color>16777215</Color>
      <ReviewColor>0</ReviewColor>
      <Type>0</Type>
    </ReleaseState>
    <ReleaseState>
      <ID>2</ID>
      <Name>Edit Review</Name>
      <GUID>FCE9451320424C1180FF976D1FFEB9D8</GUID>
      <Color>16777215</Color>
      <ReviewColor>0</ReviewColor>
      <Type>0</Type>
    </ReleaseState>
    <ReleaseState>
      <ID>7</ID>
      <Name>Obsolete</Name>
      <GUID>EB33B3F5453A4C5EBB1C781E65F074AB</GUID>
      <Color>16777215</Color>
      <ReviewColor>0</ReviewColor>
      <Type>0</Type>
    </ReleaseState>
    <ReleaseState>
      <ID>6</ID>
      <Name>Released</Name>
      <GUID>0F1514E8AAE54254BCEF464FBBF63AD0</GUID>
      <Color>16777215</Color>
      <ReviewColor>0</ReviewColor>
      <Type>0</Type>
    </ReleaseState>
    <ReleaseState>
      <ID>3</ID>
      <Name>SME Review</Name>
      <GUID>5C39F76C2B3F460FB6D62181BD53657D</GUID>
      <Color>16777215</Color>
      <ReviewColor>0</ReviewColor>
      <Type>0</Type>
    </ReleaseState>
    <ReleaseState>
      <ID>5</ID>
      <Name>Usability Testing</Name>
      <GUID>EF174B4C30724C38BC7A95D3D9617741</GUID>
      <Color>16777215</Color>
      <ReviewColor>0</ReviewColor>
      <Type>0</Type>
    </ReleaseState>
  </ReleaseStates>
  <Variables>
    <Variable>
      <ID>29</ID>
      <Name>HISTCOMMENT</Name>
      <Description>Used by Author-it to store history comments.</Description>
      <Value></Value>
      <ValueObject>0</ValueObject>
      <Style>-1</Style>
      <Prompt>false</Prompt>
      <IsVariantCriteria>false</IsVariantCriteria>
      <Type>0</Type>
      <Hidden>true</Hidden>
    </Variable>
  </Variables>
  <Information>
    <Description>XML Export</Description>
    <Date>2012-02-14T15:07:50</Date>
    <Library>
      <Name>SQLServer: AuthorIT on DEVSQL-2</Name>
      <GUID>3683c852e470441b920d01902606b8aa</GUID>
      <User>(supervisor)</User>
      <Locale>
        <ID>1033</ID>
        <Description>English (United States)</Description>
        <Code>en_US</Code>
      </Locale>
    </Library>
  </Information>
</AuthorIT>
 

 
New Post
2/16/2012 11:59 AM
 
Well, I've made some progress...

When I call objectCommonService.SaveXml(xmlImport.ToString(), false, false);
The book in the exported XML gets created, however, it lands at the root node of the library.
The book was originally exported from the A2 folder:
AuthorIt
   |__Junk
            |__A1
                    |__A2    BOOK A2TEST

After the folders get manually deleted, and then programatically recreated, and the XML folderIDs modified as in the previous post, the book gets created but it sits under theAuthroit node instead of the A2 node it came from.  The FolderID for the book is set to the ID of A2 in the XML used for the SaveXML call.  Does anyone know why it isn't being put back in the A2 folder?
AuthorIt   BOOK A2TEST
     |__Junk
             |__A1
                    |__A2

 
New Post
2/16/2012 12:55 PM
 
Andy,

I'm not totally sure what you're trying to achieve here, but I wonder if it wouldn't be better solved using the ObjectCommon move methods rather than changing the XML.

If the source and destination are in the same library then you can just use the move method.
If they are in different libraries, you can export, import, then move.

I certainly would caution against editing non-topic parts of the XML when using the SDK.

Craig
 
Previous
 
Next
HomeHomeDiscussionsDiscussionsAuthor-it Devel...Author-it Devel...Exported XML and API SaveXML functionExported XML and API SaveXML function