8

I am copying data from "legacy" components over to "new" components. For the meta data it should be a simple xml copy (replacing the namespace) i.e.

newComponent.Metadata = oldComponent.MetaData.Replace("oldnamespace", "newnamespace");

However, over the years the order of the meta data fields has changed. If the fields are not in the exact order specified in the schema I get an error telling me the field that is not in the correct order is an invalid child element.

For example, in the schema the order would be

<ExampleComponent ...>
    <Field1></Field1>
    <Field2></Field2>
</ExampleComponent>

But if I try add a component with the fields in a different order

<ExampleComponent ...>
    <Field2></Field2>
    <Field1></Field1>
</ExampleComponent>

... I get the error.

Why does the order matter? Is there a setting where I can tell Tridion to let me add elements in whatever order I like?

7

This validation is not performed by Tridion, but is a general XSD rule. The thing is that all of the Tridion web schemas have their fields in sequence element. Here's the definition of sequence from here:

The sequence element specifies that the child elements must appear in a sequence. Each child element can occur from 0 to any number of times.

You could, in theory, change sequence element with all, or group, depending on you requirements, but then you will not be able to edit fields in the UI, only in source. Check here for the list of possible children of ComplexType element and here for the description of sequence element

| improve this answer | |
  • Thanks. I don't want to start messing around with things that would break the UI. Doesn't make much sense to me why the XSD has been set up as a sequence. – Kevin Brydon Jun 20 '13 at 12:34
5

The component synchroniser would fix this for you. For an implementation that works over the core service, you could look at https://code.google.com/p/tridion-2011-power-tools/source/browse/branches/dominic/ComponentSynchroniser/. This version is still under test and awaiting integration into the power tools so you'd have to run it from code. Obviously, you'd want to review the code yourself to be sure it does what you want. Alternatively, you could use the component synchroniser from the old power tools.

| improve this answer | |
  • Thanks, I'll take a look at it. Working with the Core Service is becoming quite tiresome. – Kevin Brydon Jun 20 '13 at 12:36

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.