3

Due to some mysterious circumstances (involving Schemas and Content Porter) we have some corrupt content in our Tridion 2013 server. The namespace of the content elements does not match the parent namespace. We tried running Elena's nice script here, but no luck. Ideas?

Error message from tool is:

3:15:03 PM] Replacing namespace for component tcm:20-9096 (banner_CE_2_tcm278-1101524) - Current Namespace: uuid:945619ca-714a-4016-8575-9e378c9e457a [3:15:03 PM] Error occurred trying to update component: tcm:20-9096 System.ServiceModel.FaultException`1[Tridion.ContentManager.CoreService.Client.CoreServiceFault]: Unexpected root element: Content. Expected: uuid:3880b52d-aa6a-4838-9c26-3e0bb0f0aa4b:media-element. (Fault Detail is equal to Tridion.ContentManager.CoreService.Client.CoreServiceFault).

<media-element xmlns="uuid:3880b52d-aa6a-4838-9c26-3e0bb0f0aa4b"> 
        <item xmlns="uuid:945619ca-714a-4016-8575-9e378c9e457a" xmlns:xlink="http://www.w3.org/1999/xlink" xlink:type="simple" xlink:href="tcm:10-7758" xlink:title="myimage.jpg"></item> 
        <title xmlns="uuid:945619ca-714a-4016-8575-9e378c9e457a">Title Lorem Ipsum</title> 
        <description xmlns="uuid:945619ca-714a-4016-8575-9e378c9e457a">Lorem ipsum...</description> 
</media-element> 
  • 2013 or 2013 SP1? - In SP1 you could try using the synchronization API. – Nuno Linhares Apr 8 '14 at 13:26
  • Tridion 2013... – robrtc Apr 8 '14 at 13:36
  • It's odd that Elena's fix doesn't work for you... Any details on what it's (not) doing? – Nuno Linhares Apr 8 '14 at 16:59
  • Her script adds the new namespace to the existing components, which is good. But, the child nodes in the same component still have the old namespace, as seen above, and her scripts don't change that. – robrtc Apr 8 '14 at 18:34
  • I see - I think the use case for that tool was when the child nodes had the right NS, but not the parent node. Should be easy to adapt... I can find the source code – Nuno Linhares Apr 8 '14 at 18:36
1

The problem occurred because of Content Porter updating the namespace of the destination Schema. This makes a little sense because it assumes that my source Schema (with its namespace) is the leading version and it also assumed that I had many Components in the Source system using it. So, to help us out, Content Porter updates the namespace of the destination Schema. But, in this case, it breaks the existing Components already using the Schema of the same name on my destination server using a different namespace.

Long story short - if you want to Content Port Schemas, define the namespace yourself to something like 'http://www.tridion.com/schemas/article' and then even if Content Porter updates the Schema, we're still ok.

And, running Elena's script mentioned above fixes this issue.

However, I had another problem that the Root Namespace node name was also updated! So, I added the below functions to the script above to fix the Root Node name update.

So, in the end I changed the namespace myself to a friendly one ('http://www.tridion.com/schema/article') and then ran Elena's updated script.

private static ComponentData UpdateRootNode(CoreServiceClient client, ComponentData component)
{
    ReadOptions readOptions = new ReadOptions();
    ComponentData updatedComp =component;
    string compRootNode = GetRootNodeFromCompXml(component.Content);
    if (_schemaRootNodeName != compRootNode)
    {
        updatedComp.Content = updatedComp.Content.Replace(compRootNode, _schemaRootNodeName);
        Log("Updated root node name to " + _schemaRootNodeName);
    }

    return updatedComp;
}

private static string GetRootNodeFromCompXml(string compXml)
{
    XmlDocument doc = new XmlDocument();
    doc.LoadXml(compXml);
    string nodename = doc.DocumentElement.Name;
    return nodename;
}
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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