6

I am assigning a metadata to a folder, following is the code.

<Metadata xmlns=\"uuid:a1ee6c20-8a16-4e92-9265-9defb9bde573\">
  <folder-type>Function1</folder-type>
</Metadata>

Code works well but I have question on UUID. I have hard coded this UUID in my code. Do I need to change this UUID value if I run same code on another Tridion server?

  • Code is missing, hence is difficult to understand what UUID you are talking about. However, if it is the namespace of Metadata then it has to be the same as defined in the MetadataSchema. – Likhan Sep 3 '13 at 8:47
2

If you use Content Porter to synchronize the schemas across environments, then yes the schemas will have the same namespace URI.

A commonly used alternative is to manually set the namespace URI when creating the schema. You would adhere to the common standards here and use something like http://www.somecompany.com/[BiggerPurpose]/[SchemaName] or http://www.sdltridion.com/Metadata/FolderInfo.

You do have to be careful when changing namespaces on a schema that is already in use, as this will invalidate existing content (content will not be valid according to schema).

My preferred approach anyway is to try to determine at runtime what the namespace is, and this can be done by reading the NamespaceUri property of the Schema (or SchemaData) object in question.

| improve this answer | |
0

I guess you are referring to the Schemas UUID, if that is the case, the answer is no, this is a bad practice to use UUIDs since they change between environments. As a recommendation use URIs to define Schemas namespaces like http://mycomany/schemas/myfolderschema

| improve this answer | |
  • I did not define any schema but I have to write this schema value when i associate metadata with a folder, Is there any way to get this schema through code? I believe this is system generated schema and should be available in code. – Ali Sep 3 '13 at 4:26
  • you should specify what is a system generated schema, Tridion just generate the schemas located in the Default Templates folder during installation. If you want to retrieve the Xml Namespace through code you should use the .Net Xml namespace. – Eric Huiza Sep 3 '13 at 11:09
  • 2
    Schema.NamespaceUri will give you the value of this. – Nuno Linhares Sep 3 '13 at 13:10
  • I have TCM ID of schema, Is there any way to get schema object from that? I have tried some code but that returns xml of schema, I don't know how can i convert it to schema object. If i get the schema object then I will use "NamespaceUri" to get that value. – Ali Sep 4 '13 at 1:06
  • Schema schema = new Schema(new TcmUri("[Your Id]"), session);, that will give you the schema object. – Eric Huiza Sep 4 '13 at 1:13

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.