Tridion Stack Exchange is a question and answer site for Tridion developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am doing metadata update for Pages as below. I am constantly getting the below error

XML validation error. Reason: The required attribute '' is missing..

Code is below.

XElement xMetadata = XElement.Parse(pageData.Metadata);
XNamespace xnsp = "Tridion.Schema.Metadata.PageMetadata";
XNamespace ns3 = XNamespace.Get("");

XElement addNode= new XElement(xnsp + "add", new XAttribute(XNamespace.Xmlns + "xlink", ns3));

                foreach (var value in xxxx)

                    XElement map= new XElement(xnsp+"Map");
                    //Hard coded - TO DO
                    XElement isEnabled = new XElement(xnsp+"IsEnabled","No");
                    XElement path= new XElement(xnsp+"Path", value.Path);


                pageData.Metadata = xMetadata.ToString();

                client.Update(pageData, new ReadOptions());

One more point, metadata already consists of links to one or two configuration components. I tried adding xlink namespace to metadata root node but it dint solve the problem. Added its namespace to solve the issue but it dint help.

Let me also know if there is a better way to achieve this.

share|improve this question
It would be great, if you can share your actual metadata XML. Since your code doesn't look like proper implementation. – Siva Charan Feb 24 '14 at 14:14

According to "" namespace you are supposed to have href attribute, which you are not adding. You should get XML similar to this:

The best way to solve your porblem is to create link manually (through UI) and then make sure you recreating the same with the code.

share|improve this answer

First manually make a working page with your metadata. Then compare that to what you're making via code (hint: use the debugger or logger to inspect). This should tell you what exactly isn't right so that you can move forward.

share|improve this answer

It looks like you are constructing the XAttribute incorrectly when you say:

new XAttribute(XNamespace.Xmlns + "xlink", ns3)

Firstly, it's more idiomatic in XLinq to use the overloaded assignment operator to create an XNamespace

XNamespace xlink = "";

then you can use it (also by way of an operator overload) like this:

new XAttribute(xlink + "href", yourHrefValue)
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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