5

I have a component which was created with schema A, and contained an element in the <Content> block. Later, this component got updated, through the API, to the Image schema.

Upon publication, anything using this component fails with an error related to an unexpected namespace. After investigation, it turns out that although everything in the components looks right in the GUI, the XML of the component still contains what was in the <Content> block before the update.

Basically, it seems that Tridion merged the XML of the 2 versions instead of replacing it with the new (empty) content.

I tried to correct it using the Business connector API , and the C# TOM API, but although no error is reported while "updating" the component, the problem still persists. When opening the component through the GUI, changing the name (for instance) and saving, I got an error message saying Error: unexpected DTD:.

Any idea how to solve this? Manually deleting this components and creating copy and changing the references, is not really a solution here, for various practical reasons.

Edit: As for the C# code, I unfortunately don't have the code anymore, but we tried many different possibilities, with a lot of console output to be sure that we were sending the right XML. It involved various combinations of update(), setting the content to the XML as it should be, setting the content to null, and a save() in the end. I'll try to get the source back.

As for the SOAP API call to the business connector, here it is:

<?xml version='1.0' encoding='utf-8'?>
<tcmapi:Message xmlns:tcmapi = "http://www.tridion.com/ContentManager/5.0/TCMAPI" version = "5.0" from = "robot" failOnError = "false">
    <tcmapi:Request ID = "REQ1" preserve = "false">
        <tcmapi:SaveItem itemURI = "tcm:12-1057420" contextURI = "tcm:0-0-0" doneEditing = "true" itemType = "Component">
            <tcm:Component ID = "tcm:12-1057420" IsEditable = "false" xmlns:tcm = "http://www.tridion.com/ContentManager/5.0" xmlns:xlink = "http://www.w3.org/1999/xlink">
                <tcm:Context>
                    <tcm:Publication xlink:type = "simple" xlink:title = "Internet Content Parent" xlink:href = "tcm:0-12-1"/>
                    <tcm:OrganizationalItem xlink:type = "simple" xlink:title = "Main Images [530,200,100]" xlink:href = "tcm:12-108162-2"/>
                </tcm:Context>
                <tcm:Info>
                    <tcm:LocationInfo>
                        <tcm:WebDAVURL>/webdav/Internet%20Content%20Parent/Building%20Blocks%20Management/General%20Content/[redacted]/Main%20Images%20%5B530%2C200%2C100%5D/Imagejpg</tcm:WebDAVURL>
                        <tcm:Path>\Internet Content Parent\Building Blocks Management\General Content\[redacted]\Main Images [530,200,100]</tcm:Path>
                    </tcm:LocationInfo>
                    <tcm:BluePrintInfo>
                        <tcm:OwningPublication xlink:type = "simple" xlink:title = "Internet Content Parent" xlink:href = "tcm:0-12-1"/>
                        <tcm:IsShared>false</tcm:IsShared>
                        <tcm:IsLocalized>false</tcm:IsLocalized>
                    </tcm:BluePrintInfo>
                    <tcm:VersionInfo>
                        <tcm:Version>5</tcm:Version>
                        <tcm:Revision>0</tcm:Revision>
                        <tcm:CreationDate>2013-05-16T13:54:20</tcm:CreationDate>
                        <tcm:RevisionDate>2013-07-03T10:22:51</tcm:RevisionDate>
                        <tcm:Creator xlink:type = "simple" xlink:title = "[redacted]" xlink:href = "tcm:0-3751-65552"/>
                        <tcm:Revisor xlink:type = "simple" xlink:title = "[redacted]" xlink:href = "tcm:0-3751-65552"/>
                        <tcm:ItemLock Title = "No lock" Type = "0"></tcm:ItemLock>
                    </tcm:VersionInfo>
                    <tcm:PublishInfo xmlns:tcm = "http://www.tridion.com/ContentManager/5.0" xmlns:xlink = "http://www.w3.org/1999/xlink">
                        <tcm:IsPublished>false</tcm:IsPublished>
                    </tcm:PublishInfo>
                    <tcm:WorkflowInfo>
                        <tcm:ProcessInstance xlink:type = "simple" xlink:title = "" xlink:href = "tcm:0-0-0"/>
                        <tcm:ActivityInstance xlink:type = "simple" xlink:title = "" xlink:href = "tcm:0-0-0" Description = ""/>
                        <tcm:Assignee xlink:type = "simple" xlink:title = "" xlink:href = "tcm:0-0-0"/>
                        <tcm:Performer xlink:type = "simple" xlink:title = "" xlink:href = "tcm:0-0-0"/>
                        <tcm:CreationDate></tcm:CreationDate>
                        <tcm:StartDate></tcm:StartDate>
                        <tcm:FinishDate></tcm:FinishDate>
                        <tcm:PreviousMessage></tcm:PreviousMessage>
                    </tcm:WorkflowInfo>
                    <tcm:AllowedActions xmlns:tcm = "http://www.tridion.com/ContentManager/5.0">
                        <tcm:Actions Allow = "125321" Deny = "614" Managed = "0"/>
                    </tcm:AllowedActions>
                </tcm:Info>
                <tcm:Data>
                    <tcm:Title>Image</tcm:Title>
                    <tcm:Type>Multimedia</tcm:Type>
                    <tcm:Schema xlink:type = "simple" xlink:title = "dtd_picture" xlink:href = "tcm:12-49-8"/>
                    <tcm:Content></tcm:Content>
                    <tcm:Metadata>
                        <Metadata xmlns = "urn:DTD49">
                            <date_publish>2013-05-28T10:00:00</date_publish>
                            <MM_Height>265</MM_Height>
                            <MM_Width>530</MM_Width>
                            <MM_Alt>WX520</MM_Alt>
                            <popupScreen>800x600px</popupScreen>
                            <popupScrollbars>No</popupScrollbars>
                            <popupToolbars>No</popupToolbars>
                        </Metadata>
                    </tcm:Metadata>
                    <tcm:ApprovalStatus xlink:type = "simple" xlink:title = "Undefined" xlink:href = "tcm:0-0-0"/>
                    <tcm:IsBasedOnTridionWebSchema>true</tcm:IsBasedOnTridionWebSchema>
                    <tcm:UploadedMultimediaFilename>D:\[redacted]\binaries\12-1057420</tcm:UploadedMultimediaFilename>
                    <tcm:MultimediaFilename>C:\[redacted]\Image.jpg</tcm:MultimediaFilename>
                    <tcm:MultimediaFileSize>49870</tcm:MultimediaFileSize>
                    <tcm:IsExternalMultimediaFile>false</tcm:IsExternalMultimediaFile>
                    <tcm:MultimediaType xlink:href = "tcm:0-2-65544" xlink:title = "Jpeg image"/>
                </tcm:Data>
            </tcm:Component>
        </tcmapi:SaveItem>
    </tcmapi:Request>
</tcmapi:Message>

The XML of the "updated" component is:

<tcm:Data>
  <tcm:Title>Image</tcm:Title>
  <tcm:Type>Multimedia</tcm:Type>
  <tcm:Schema xlink:type="simple "xlink:title="dtd_picture "xlink:href="tcm:12-49-8"IsMandatory="false" />
  <tcm:Content>
     <Download>
        <title>Title</title>
        <operatingSystem>Not Applicable</operatingSystem>
        <language>EN</language>
        <language>FR</language>
        <language>ES</language>
        <language>IT</language>
        <language>DE</language>
        <language>RU</language>
        <language>JA</language>
        <language>ZH</language>
        <descriptionShort> Description. </descriptionShort>
        <descriptionLong />
        <precaution />
        <softwareLicenseAgreement />
        <history />
        <environment />
        <setup />
     </Download>
  </tcm:Content>
  <tcm:Metadata>
     <Metadata>
        <date_publish>2013-05-28T10:00:00</date_publish>
        <MM_Height>265</MM_Height>
        <MM_Width>530</MM_Width>
        <MM_Alt>WX520</MM_Alt>
        <popupScreen>800x600px</popupScreen>
        <popupScrollbars>No</popupScrollbars>
        <popupToolbars>No</popupToolbars>
     </Metadata>
  </tcm:Metadata>
  <tcm:ApprovalStatus xlink:type="simple" xlink:title="Undefined" xlink:href="tcm:0-0-0" />
  <tcm:IsBasedOnTridionWebSchema>true</tcm:IsBasedOnTridionWebSchema>
  <tcm:MultimediaType xlink:type="simple" xlink:title="Jpeg image" xlink:href="tcm:0-2-65544" />
  <tcm:MultimediaFilename>C:\[redacted]\Image.jpg</tcm:MultimediaFilename>
  <tcm:MultimediaFileSize>49870</tcm:MultimediaFileSize>
  <tcm:IsExternalMultimediaFile>false</tcm:IsExternalMultimediaFile>

The whole <Download> block has nothing to do here.

4
  • Can you post the code you're using to update the component(s) through the API? Commented Feb 24, 2014 at 11:39
  • @NVanderEnde: I updated the question.
    – m4573r
    Commented Feb 24, 2014 at 12:16
  • If you want to remove the entire "Download" section, and we're only talking about this one Component, you should be able to just edit the Source tab in the GUI and delete the whole section. Make sure you leave the <tcm:Content/> element in there, though. Commented Feb 24, 2014 at 13:12
  • @PeterKjaer: since it's just an image component, there is no "source" tab in the gui :/
    – m4573r
    Commented Feb 24, 2014 at 13:46

2 Answers 2

1

Take a look at the code in Dom's Component Synchronizer here for some ideas on how to fix the XML: https://code.google.com/p/tridion-2011-power-tools/wiki/ComponentSynchronizer

You can also try installing the legacy Component Synchronizer Powertool and see if that fixes the XML. You can find it here: http://sdltridionworld.com/community/extension_overview/powertools.aspx

If those tools can't tackle it, then your XML is FUBAR, or it's some silly small thing that the machine can't figure out. Try this to find the culprit: in your new schema temporarily make all fields unmandatory. Try to save your messed component. Then start taking content items out one by one and try to save until you find the field that's troublesome.

If writing Core Service code to manipulate the XML, make sure you enable all the ReadOptions via LoadFlags so you can see the entire XML. More info here and then the Tridion CS API: How to Get Keyword from Metadata or Item XML Using Core Service

3
  • The component synchronizer didn't work, and no luck with the rest either :/
    – m4573r
    Commented Feb 25, 2014 at 14:57
  • What do you mean "no luck with the rest"? Can you create a component using the Tridion GUI against the same schema with the exactly the same data as the erroneous compoonent? If so, did you try doing a diff of the XMLs? And if you did that, please point out to us what that diff was. Commented Feb 25, 2014 at 15:22
  • I can create a component with the same schema (which is just the classical image one, with no mandatory field but the title), but not with the same data than the problematic component, since well, this data is part of another schema. The culprit here is the whole "update the schema of the component" through the api, which is apparently not properly supported entirely.
    – m4573r
    Commented Feb 26, 2014 at 1:12
1

In the "old" days when I used to update components using the TOM API I would use the UpdateXML() call to update the entire Tridion XML of the item in question. My guess is you got into this mess by switching only the schema (thus leaving the content intact) and ended up with an invalid combination of both (this is most likely the reason why the WebGUI doesn't allow you to change the schema of an existing component!).

Perhaps you can give this a try?

Dim comp : Set comp = TDSE.GetObject("tcmuri-of-component", 2)
comp.UpdateXML("intended target xml for component")
comp.Save(True)

Note that the language is VBScript (you'll need slightly different syntax for JScript). The XML to put in would be as you posted but with an empty or absent <tcm:Content> node...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.