15

When creating a new Schema in Tridion there is an entry field called 'Root Element Name'. The default is content but I am not sure what this does.

4 Answers 4

17

This is the name of the first XML element in your content.

If a component is represented like this:

<Content>
  <Name>Hello</Name>
  <Description>I am a component</Description>
</Content>

Then Content is the Root Element name. If you would modify your schema to have a Root Element Name of Article then your component's XML would be:

<Article>
  <Name>Hello</Name>
  <Description>I am a component</Description>
</Article>

PS - for simplification, I am omitting XML namespaces from the examples.

EDIT

Some other answers mention it - and it is correct - so I'm adding it here for future reference.

This is an important setting to change on Embedded Schemas, if you ever need to use 2 different embedded schemas as part of the same "main" schema, they must have different Root Element Names or your XML will not be valid:

<Article>
  <Name>Hello</Name>
  <Description>I am a component</Description>
  <Content>
    <Field>And I am an embedded Field in an embedded schema</Field>
  </Content>
  <Content>
    <Description>And I am an embedded Field in another embedded schema</Description>
  </Content>
</Article>

As the example above shows, if both embedded schemas would have a Root Element Name of Content then you'd have a hard time figuring out which is which, especially if one of the embedded schemas fields allowed multiple values.

When adding an Embedded Schema Field, Tridion will validate that all Embedded Schemas have a different Root Element Name, and if that's the case then it won't let you save it - you'll have to go find that schema and modify the root element name - meaning you may now have content that is out of sync with its schema (if it was used already).

In short: always rename the Root Element Name of your embedded schemas. Rename the Root Element Name of your Content schemas if it makes sense to you. Do not rename it after you already have content based on that schema, that's asking for trouble.

2
  • 2
    The names we pick matter most for embeddable schema, where we'll get a namespace conflict if using embeddable schema with the same root element name. A good practice would be to give unique names for at least embeddable schema. Commented Nov 25, 2013 at 22:24
  • ...and even a better practice would be to give unique names to all Root Element Names in all Schemas that allow you to specify one. Commented Nov 27, 2013 at 18:19
4

In our implementation, we keep the combination of root element name and namespace of every schema unique. These two elements are more technical and not available to the content editors.

If the template code needs to check for a specific schema, this combination can be validated instead of validating the schema name. Schema name may have to be changed if content editors recommend a better name.

4

The answer has already been given: "It is the name of the first node in your XML." I do want to stress that in the case of embeddable Schema's, the XSD gives an error when you have 2 sorts of Embeddable schema's with the same root element name.

So be sure to keep it unique. The root element name can be changes, but you want to prevent that.

3

I would like to add that controlling of 'Root element name' and namespaces are extremely important especially if you use XSLT as a templating solution.

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.