2

From earlier posts I found responses that one of the most common way to validate a content component or keyword, or whatever, is to open the component and try to save it.

What is the advised process to test, if a component is valid against it's schema, in a multipublication environment like below?
Pub1->Pub2(child publication)

  • There may be a certain localized schema under Pub2 different than under Pub1. It may have changed under pub2, so that the same content coming from pub1 could be valid against a certain schema from pub1, but the same component under pub2, could be invalid against the localized(but same tcm) schema under pub2. How to validate a component under Pub2 in this case, which is not localized yet there under pub2?

    • should lokalize the content component under Pub2, try to save it if it fails, then it's invalid under pub2.
    • After trying to save it, should unlocalize the component to restore the original state
    • if the component was localized already, should only try to save the component, but after the save test, if the save succeeded, then should rollback the operation in order to restore the original state of the component.

      1. Is this a realistic scenario at all? To have a localized and changed, incompatible schema under a child publication?
      2. The approach I described should be taken, right? I mean, it would NOT be OK to try to save the component inside the publication where it comes from? As it should be valid under the "target" publication, right? But not sure how realistic is that... It involves more work and more steps to go through this process.

Asking your opinion because I'm in progress of automatizing component validation... and wondering if I'm overthinking this or not, do I relly have to implement the above processes of localizing, saving, unlocalizing, rolling back, etc. or it could be made more simple?

Thanks, bvl

2 Answers 2

3

You can use ICoreService2012.ValidateXml method. It takes component data as and argument an will automatically find the corresponding schema and will check if current component is valid against its schema

5
  • Hi! Thanks! is this core service available for SDL Tridion 2011 too? Is there a way on GUI to trigger this function?
    – BVL
    Commented Jan 30, 2014 at 9:35
  • In the UI there is a button Validate that should do the trick.
    – Likhan
    Commented Jan 30, 2014 at 9:46
  • now I understand. That validatexml only checks for the certain field types, where we can add XHTML. It can tell if the entered code is XML or not...Also the VALIDATE button on GUI checks only the same. I'm asking about checking against the Schema file of a content component, checking all fields, metadata etc. of a certain content component. As you know a schema file can be changed anytime, which means the old contents may become invalid agains the new changed schema file. For example if we add a new mandatory field to a schema but old components doesn't have that field-> it gets invalid then.
    – BVL
    Commented Jan 30, 2014 at 9:54
  • ValidateXml will check for all fields and metadata Commented Jan 30, 2014 at 11:38
  • Ok. Validate button on GUI, checks only the XHTML field's XML validity, while the core service validateXml really validates the whole component agains it's schema definitions, including mandatory fields, etc. Thanks!
    – BVL
    Commented Jan 30, 2014 at 12:55
5

AFAIK you cannot change schema structure in a localized schema, you can only change the display name/description of the fields. So in a child publication a shared component cannot be invalid. However, your component can still become invalid if the schema has changed in the original publication (Pub1). And as @user978511 suggests you can use the ValidateXml method to validate component.

5
  • so there is no meaning of localizing under pub2 the components and checking them there as the schema can not change its structure even after it's localized under a child pub. Then saving it at the original(parent) publication level is the only option via GUI? I mean without core services? I suppose the same is valid for all versions of Tridion? Thanks, Likhan!
    – BVL
    Commented Jan 30, 2014 at 9:38
  • Indeed. As long as the component is valid in the publication where it is created and localized it should be valid in all shared publication.
    – Likhan
    Commented Jan 30, 2014 at 9:45
  • thanks, Likhan, about Validate button on GUI, see my comment above. I was unable to find specification of that core service, could you share with me a link to docs? I have a feeling that it does not validate the whole content componnet, it only does a syntax validation of the XHTML fields, but not a full and direct validation against the schema the component uses. Thanks!
    – BVL
    Commented Jan 30, 2014 at 9:56
  • You are most likely correct the Validate button in UI only does validation of the XHTML fields. AFAIK ICoreService2011.ValidateXml should also check for mandatory fields. Documentation is available sdltridionworld.com/downloads/documentation/SDLTridion2011SP1/… (login required). BTW, this method was most likely introduced in 2011SP1.
    – Likhan
    Commented Jan 30, 2014 at 10:28
  • Thanks, Likhan! So through GUI there is no way to validate? Except of course by trying to save the component. To bad that VALIDATE only checks for XHTML field validity and not validates the actual component against it's Schema. Or is there a way to do that? Via a GUI extension may be?
    – BVL
    Commented Jan 30, 2014 at 12:53

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.