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

Community Tip - Learn all about PTC Community Badges. Engage with PTC and see how many you can earn! X

Checking context

TomLeoboldt
1-Newbie

Checking context

Hello all,

I am looking for an ACL function that will interrogate the DTD and tell me whether a given element is contextually correct for insertion before the first element in the exising SGML document. I know that the insert_tag function returns 1 on success and 0 on failure, but I need to know whether an element can be inserted in the current context before the insert_tag function is called.

For example, the current docuement may contain only <section> elements which in turn contain <para> elements. For the sake of this example, lets say that <section elements can only be wrapped by <book> elements and not <magazine> elements. If the user executes a custom ACL function designed to wrap the current document in a <magazine> parent element, I want to systematically determine that this is an invalid action and notify the user before calling the insert_tag function and reacting to its error status.

I’ve read about the content_model function that returns the content model for a given element. Are there any existing functions that accept an element name and return true of false regarding whether a given element is included in that text that content_model returns?

Any help will be greatly appreciated.

1 REPLY 1
SirkoRudolph
5-Regular Member
(To:TomLeoboldt)

Hi Tom,

Did you consider using the in_context() function? If you place the cursor before the first element where you want to insert the tag, it should tell you if that tag can be inserted at that position, either directly or with modifications (by returning 1 or 2 respectively).

Hope this helps (and doesn't come too late).

Kind regards

Sirko

Top Tags