cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - You can change your system assigned username to something more personal in your community settings. X

OID required?

ebenton
1-Newbie

OID required?

Is there a way in ACL to tell whether or not a given OID is a required element (by the DTD)? I can't find anything about it in the Help. Required attributes I can find, but required elements, no.
8 REPLIES 8
bibach
1-Newbie
(To:ebenton)

Hey, Ed...

Check out the cut_valid() or delete_markup_valid() ACL functions. One
of these will probably do the trick.

-Brandon 🙂

Ed,

I'd wager there is. If Brandon's solution doesn't work, I'd trace back to see what code identifies the insert required tags.

Lynn

---- "Benton wrote:
> Is there a way in ACL to tell whether or not a given OID is a required element (by the DTD)? I can't find anything about it in the Help. Required attributes I can find, but required elements, no.
>
> -----End Original Message-----

Ed,

I did some quick looking and really didn't see anything jump out at me. You may want to take a look in the _smartinsert.acl file in the \tools folder. You may be able to work something from that. However, looking at that made me stop and think. What do you mean by 'required tag'?

Required from the root element, required as part of a child of the root (even if the child is optional) or what? There are times when you add an optional element that you now force new tags to be required. So finding them may not be as easy as I would like to think.

I'm willing to say that you could work something out from the add required tags code to load an array of those required OID's and then look through it to verify whether the tag at that OID is required or not.

Lynn

Lynn

---- Lynn Hales <-> wrote:
> Ed,
>
> I'd wager there is. If Brandon's solution doesn't work, I'd trace back to see what code identifies the insert required tags.
>
> Lynn
>
> ---- "Benton wrote:
> > Is there a way in ACL to tell whether or not a given OID is a required element (by the DTD)? I can't find anything about it in the Help. Required attributes I can find, but required elements, no.
> >
>

Ed,

Going on the information from Brandon, you can use cut_valid( $oid ) to test if the oid can be deleted. If the DTD will allow the current oid to be deleted, then the function will return a "1" implying that the oid is an optional element, according to the DTD, at the current location. If it returns a "0", then it cannot be deleted, and therefore is "required" by the DTD at the current location.

Just because the function is used to test the ability to cut the OID does not mean you are going to actually delete it. The code I would use is as follows:

$o = $current_OID ;

if ( cut_valid( $o ) {

...code for OID is"optional" ...

} else {

... code for OID is "required" ...

}

Hope this helps,

Bob

Correction...

if ( cut_valid( $o ) ) {

sorry...

Thank you, that is valuable information.

Ed,

What Brandon started and Ed embellished on does make sense. But I am still trying to get a good handle on what you mean by required. For example:



Which elements are truly 'required'? and <f> certainly are, but are <c> and <d>? When <c> is used, both <c> and <d> must be provided, but they are not truly required by the DTD.

The coding that Bob shows would say they are because if you try to remove either <c> or <d>, then the markup would become invalid. Like wise if you tried to insert <c> as an after thought, it would not work because that would make <e> and certainly <f> out of context. You would have to either start the elements in an ASCII editor then copy and paste or turn context checking off while you inserted first <c> then <d>.

So depending on what you mean by 'required' will determine if the 'cut_valid()' approach will give you what you want.

Lynn

---- "Benton wrote:
> Thank you, that is valuable information.
>

We're trying to use it in a scenario where we are attempting to execute an ACL function that involves deleting (aka cutting) an element which would cause a context error, in which case we want to not allow the execution and notify the user of the reason why the function cannot be executed.
Announcements

Top Tags