General XMetaL Discussion
pooh2583 February 18, 2013 at 10:31 am
Adding Additional functionality into Xmetal Validator/F9February 18, 2013 at 10:31 amParticipants 3Replies 4Last Activity 9 years, 7 months ago
I need to add some additional code in the Xmetal's inBuilt Validator/F9, Which will Validate whether the contents of some elements is valid or not.
Could you please explain how to achieve this functionality.
RegardsDerek Read February 18, 2013 at 7:10 pm
Reply to: Adding Additional functionality into Xmetal Validator/F9February 18, 2013 at 7:10 pm
The Journalist sample will explain everything you need to know, including which events to use and how to inject messages into the Validation Log. You'll need to come up with your own validation logic to match your specific rules but the framework is there.
Open the journalist.mcr and search for these events:
To see this in action:
1. Open the “Cameras in Focus (Journalist)” demo in Help > Samples.
2. In the XFT form at the top of the document enter an invalid email address (such as “asdf”). Press F9 to validate.
3. Select one of the images and, using the Attribute Inspector, add a space into the FileRef attribute. Press F9 to validate.Derek Read February 18, 2013 at 10:17 pm
Reply to: Adding Additional functionality into Xmetal Validator/F9February 18, 2013 at 10:17 pm
Note that you might also make such changes automatically if it makes more sense to do so. That assumes you can predict the “mistakes” that users will make and there is only one correction. There is no demo for this, but you can alter a document just before it is saved using On_Before_Document_Save or On_Before_Document_SaveAs. Or you might do it in On_Before_Document_Validate (which fires before both of the previous events and whenever the user presses F9).
One example of what you might do in this case would be to alter the Journalist demo so that it doesn't warn that spaces aren't allowed in that @FileRef but automatically converts them to %20 instead. This could be done inside On_Before_Document_Validate. Then the user doesn't need to worry about entering spaces in @FileRef because they will be changed automatically. Some users might eventually start entering %20 instead (if they notice) but they wouldn't have to.
For users that might be confused by seeing %20 later on (in their XML source or the Attribute Inspector) I would recommend providing an XFT that automatically does the conversion both ways so that when they look at the value in the XFT they see the space (or whatever you are changing) while the XML source remains unaffected, and if they enter a space into the XFT you could also convert it when the XFT is writing out to the XML source (though the On_Before_Document_Validate script would eventually fix those up).
For attributes there is also a special set of events that let you deal with attribute values right after a user has entered them into the Attribute Inspector. They are On_Before_Set_Attribute_From_AI and On_After_Set_Attribute_From_AI. They only fire when the user is interacting with the AI though, so if they change attributes in an XFT you have created you will need to code your logic into the form as well. They might also enter them directly into the XML source in Plain Text view — but in that case do they really need that much hand holding? To be completely “safe”, using the events described at the start of this post would ultimately fix things up so even if you provide this logic in an XFT you may wish to implement one or more of those first events anyway.pooh2583 February 19, 2013 at 5:50 am
Reply to: Adding Additional functionality into Xmetal Validator/F9February 19, 2013 at 5:50 am
Thank you for your reply
I would like to know what regular expression pattern should I use to allow patern like this I need to validate the value in the attribute for a specific node.
these are some valid pattern, null is not allowed
124576 780645 365890
789958 976454 655588 694379
invalid patterns are
678 569765 67
i.e 1st set of 6 decimal is mandatory and another 0 to any no. of set of decimal no separated by sapce
if the more than 0 sets are present then they should be separated by a space and each set have only 6 digits
RegardsDerek Read February 19, 2013 at 6:17 pm
Reply to: Adding Additional functionality into Xmetal Validator/F9February 19, 2013 at 6:17 pm
Be sure to do testing there using Internet Explorer to be sure that the JScript engine is being used.
- You must be logged in to reply to this topic.