Take the 2-minute tour ×
Tridion Stack Exchange is a question and answer site for Tridion developers and administrators. It's 100% free, no registration required.

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

share|improve this question

2 Answers 2

up vote 3 down vote accepted

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

share|improve this answer
    
Hi! Thanks! is this core service available for SDL Tridion 2011 too? Is there a way on GUI to trigger this function? –  BVL Jan 30 at 9:35
    
In the UI there is a button Validate that should do the trick. –  Likhan Jan 30 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 Jan 30 at 9:54
    
ValidateXml will check for all fields and metadata –  user978511 Jan 30 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 Jan 30 at 12:55

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.

share|improve this answer
    
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 Jan 30 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 Jan 30 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 Jan 30 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 Jan 30 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 Jan 30 at 12:53

Your Answer

 
discard

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.