US 7895516 B2
A document assembly or document automation system includes an assembler for generating an instance document on the basis of a source document and one or more logic source documents referenced by the source document. The source document and logic source documents are XML documents including at least one XML processing instruction. The source document and logic source documents are valid with respect to XML schema. The system generates an instance document in HTML, PDF or RTF format by resolving variables in the source document and/or logic sources using one or more data sources. This may involve performing one or more interview rounds with a user of the system, access to a database, and/or evaluation of a function defined in one of the documents. The system includes an editor for creating and maintaining source documents and logic source documents whilst maintaining their validity with respect to the appropriate XML schema.
1. A computer-readable storage medium having instructions stored thereon, which when executed cause a machine to perform a set of operations comprising:
generating at least one instance document from at least one XML source document for a document assembly system; and
determining content at locations of said at least one instance document based on document assembly instructions associated with corresponding locations within said at least one XML source document;
(i) said at least one XML source document was created by associating said document assembly instructions with at least one initial XML document;
(ii) said at least one initial XML document is valid with respect to a predetermined DTD or schema that does not include said document assembly instructions;
(iii) said at least one XML source document is valid with respect to the same predetermined DTD or schema as said at least one initial XML document; and
(iv) at least one of said document assembly instructions is associated with one or more corresponding portions of said at least one XML source document, and defines one or more conditions that determine whether the one or more corresponding portions of said at least one XML source document will be included in said at least one instance document.
2. The computer-readable storage medium as claimed in
3. The computer-readable storage medium as claimed in
4. The computer-readable storage medium as claimed in
5. The computer-readable storage medium as claimed in
6. The computer-readable storage medium as claimed in
7. The computer-readable storage medium as claimed in
8. The computer-readable storage medium as claimed in
9. The computer-readable storage medium as claimed in
10. The computer-readable storage medium as claimed in
11. The computer-readable storage medium as claimed in
12. The computer-readable storage medium as claimed in
13. The computer-readable storage medium as claimed in
14. The computer-readable storage medium as claimed in
15. The computer-readable storage medium as claimed in
16. The computer-readable storage medium as claimed in
17. The computer-readable storage medium as claimed in
18. The computer-readable storage medium as claimed in
19. The computer-readable storage medium as claimed in
20. The computer-readable storage medium as claimed in
21. The computer-readable storage medium as claimed in
22. The computer-readable storage medium as claimed in
23. The computer-readable storage medium as claimed in
24. The computer-readable storage medium as claimed in
25. The computer-readable storage medium as claimed in
26. The computer-readable storage medium as claimed in
27. The computer-readable storage medium as claimed in
28. The computer-readable storage medium as claimed in
29. The computer-readable storage medium as claimed in
This is a non-provisional application claiming the benefit of International application number PCT/AU03/00253 filed Feb. 28, 2003
The present invention relates to document assembly or document automation, and in particular to a document assembly system, and methods executed by components of the system.
Document assembly refers to the generation of an instance document from one or more source documents. In general, a source document is a generic template document, and additional information specific to the relevant circumstances is required to generate an instance document from one or more source documents. This additional information can originate from a user and/or some other data source. Document assembly software has been developed for generating documents that typically contain large amounts of common text or data with a smaller amount of varying detail text or data. Document assembly software is useful because, where a suitable source document exists, it enables instance documents to be produced more efficiently than may otherwise be the case using a standard word processor. A form letter is perhaps the simplest and most familiar example of a source document, and can be used to generate instance letters for a number of recipients. An instance letter is typically generated from a single source document and addressee information, such as the addressee's first and last names, title, and address. More complex instance documents, such as legal or financial documents, can be generated from one or more source documents, based on information specific to the parties involved and the circumstances of their relationships.
A source document is represented in a document assembly system in some data format. Common data formats (only some of which are commonly used for source documents for a document assembly system) include plain text, Microsoft's proprietary Microsoft Word “doc” format, the rich text format (RTF), portable document format (PDF), and hypertext markup language (HTML). A data format which is now being used for a wide variety of applications is extensible markup language (XML), as described at http://www.w3.org/XML. An XML document combines the text of a document with tags that markup that text into logical elements. As a data format for storing documents generally, XML has a number of advantages over other data formats. In particular, XML can be used to markup text in a way that tags it with its meaning or purpose, and applications can manipulate the text on the basis of these tags. Tools for parsing and manipulating XML data are available from a variety of vendors.
XML allows a document grammar to be defined which an XML document must match if it is to be said to be valid with respect to that grammar. If a document is valid, then systems that can handle documents matching that grammar can manipulate those documents taking advantage of the grammar. Such a grammar is often contained within a “document type definition” (DTD) or “XML schema”. There are many different grammars for XML documents that are designed to meet specific needs. For example, the DocBook document type definition, documented at http://www.oasis-open.org/docbook/xml/, was designed to meet very general documentation requirements.
A document assembly system preferably performs a number of basic functions. First, it determines, on the basis of data provided to it, which parts of a source document to include in or exclude from a resulting instance document. For example, a paragraph, sentence or phrase might only be included in a legal contract if there is a guarantor. Second, the system can also include in the instance document text which is not present in the source document. For example, a date, an address, or where a user of the system enters a yearly rental, the amount calculated to be payable per calendar month. In order to be able to provide these two basic functions, a document assembly system stores (i) information as to which parts of the source document may be included or excluded from the instance document, and (ii) information as to the locations in the document in which additional text may be inserted.
It is also desirable to be able to repeat a passage of text a specified number of times, but with different data inserted at certain points within the passage in each repetition. This requires the ability to identify the passage to be repeated, the number of times to repeat it, and the data to be inserted into each repetition.
Existing document assembly products that work with source documents which are not XML based often encode the information described above directly in the source document. This is possible with XML source documents as well. The information could be stored as additional elements or attributes in the XML document itself. However, a serious difficulty with this approach is that the document will not be valid unless the grammar is altered to allow the inclusion of that information.
In an alternative approach, taught in U.S. Pat. No. 6,006,242 (Poole, et al. “Apparatus and method for dynamically creating a document”), entity references are embedded in a document instance, and a dedicated entity resolver is used during the document assembly process to replace the entity references with text particular to the instance document. One problem with this approach is that the source document will not validate against the original grammar unless the validating parser being used uses that dedicated entity resolver.
Because in each of these approaches the document no longer validates against the original grammar using a validating XML parser, the ability to manipulate the document with 3rd party XML-aware applications is significantly curtailed.
It is desired to provide a document assembly method and system, a method for generating a source document for a document assembly system, a source document for a document assembly system, a logic source for a document assembly system, and a grammar for a logic source for a document assembly system that ameliorate one or more of the above difficulties, or at least provide a useful alternative.
In accordance with the present invention there is provided a document generation system, including:
The present invention also provides a method for generating an XML source document for a document assembly system, including:
The present invention also provides a document assembly method, including:
The present invention also provides a document assembly system, including a processing engine for generating an instance document from at least one XML source document and one or more logic sources associated with said at least one XML source document, wherein said at least one XML source document is valid with respect to a predetermined DTD or schema.
The present invention also provides a document assembly system, including an editor for generating an XML source document by associating an initial XML document with logic for use in generating an instance document from said XML source document, said initial XML document and said XML source document being valid with respect to the same predetermined DTD or schema.
The present invention also provides an XML source document for a document assembly system, said XML source document including one or more assembly instructions for determining content of an instance document, said XML source document being valid with respect to a predetermined DTD or schema.
The present invention also provides a logic source for a document assembly system, said logic source including one or more logic elements for determining content of an instance document from an XML source document associated with said logic source, said XML source document being valid with respect to a predetermined DTD or schema.
Preferred embodiments of the present invention are hereinafter described, by way of example only, with reference to the accompanying drawings, wherein:
In this specification, a reference to a document includes a reference to entries in a file system, database or other library, which can be taken together to represent the document. A reference to a document includes a reference to a collection of documents.
As shown in
The document assembly modules 108 include a Java controller servlet 218, a processing engine 202 and a rendering engine 204. The Java controller servlet 218 was created using the Java Development Kit available from Sun Microsystems®, and provides an interface between the other document assembly modules and the servlet container 216. A user of the computer system 114 can access the document assembly system using a web browser application executing on the computer 114. HTTP requests generated by the browser are sent over the network 116 and are received by the HTTPD servlet container 216. Access to the document assembly modules 108 is provided via the Java Servlet 218, which in turn invokes the processing engine 202 to generate an instance document on the basis of the document assembly data files 110. The instance document is rendered by the rendering engine 204 to generate a rendered document which is sent to the user's web browser via the Java controller Servlet 218.
The data files 110 include source documents 208, logic sources 210, document grammars 212, and logic grammars 214. The data files 110 may also include stored response data 215. In the described embodiment, the server 102 is a standard computer server such as a Sun Fire® 15K server from Sun Microsystems® and executing a Solaris® operating system, and the processing modules 106, 108, and 112 of the document assembly system are implemented as software modules stored on hard disk storage 104 of the server 102. The data sources 110 are data files also stored on the hard disk storage 104. However, it will be apparent that the modules of the document assembly system can alternatively be distributed over a variety of locations, and that at least part of the modules 106, 108, and 112 can be alternatively implemented as dedicated hardware components such as application-specific integrated circuits (ASICs).
The document assembly system generates instance documents from one or more generic source documents 208 on the basis of information provided by one or more data sources. The data source is typically a user of the system, but other data sources can be used in addition to, or instead of, a user. In the case when a user is a data source, this information is provided in the form of responses to questions generated by the system on the basis of information contained in logic sources 210. The document assembly system uses XML as the data format for representing source documents 208 and logic sources 210. In addition to elements used for structuring data, XML defines a comment and a processing instruction (PI). A processing instruction is not part of a document's usual character data, but is instead passed through to an application. Thus a processing instruction can be included in a document without affecting its validity. The form of a PI can be represented as follows:
The information in the processing instruction is not itself checked by a parser at all (apart from ensuring it begins with a string PITarget, used to identify the target application for the PI). Moreover, processing instructions can be placed anywhere in an XML document. The document assembly system uses PIs to separate logic used to generate an instance document from the source document itself. A source document 208 includes references to external logic sources 210 that are required to resolve the logic contained in the source document 208 itself.
A source document 208 is a structured XML document, usually including one or more processing instructions, as described above. Some of these processing instructions include logic components that are used to determine the content of instance documents generated from the source document 208. The logic in a source document 208 is resolved using logic from one or more external logic sources 210. A logic source required by a source document 208 is identified by a reference (in the form of a universal resource indicator (URI)) in a processing instruction. The logic sources 210 are themselves structured XML documents that define questions, conditions, and reusable text objects. The processing engine 202 uses the XML parser 206 to read source documents 208 and logic sources 210. A logic source 210 can include one or more references to other logic source documents 210. The source documents 208 are described by document grammars 212, against which the source documents 208 can be validated. Similarly, the logic sources 210 can be validated against logic grammars 214.
The processing engine 202 resolves logic associated with an XML source document 208. When a user of the system is used as a data source, the logic is resolved by performing one or more question and answer interview rounds that determine which components and text from the source documents 208, referenced logic sources 210 and user responses are included in the resulting instance document.
A logic source includes XML elements that are used to determine values for variables required by a source document or other logic source referring to that logic source. These variable values are usually determined from responses provided by a user of the system in response to questions defined in one or more logic sources 210 referenced by the source document, either directly or indirectly via a chain of references. The process of displaying questions to the user and receiving responses to those questions is referred to as an interview, and the data defining these questions and possible responses to them is referred to as interview data. A given set of responses to a set of questions can be stored as stored response data 215 on the hard disk 104 of the document assembly system. The user's responses are used to assign values to variables, such as setting Boolean variables to a value of true or false for determining whether an associated portion of text is to be included in a generated instance document. These variables values are referred to as assembly data.
During the course of resolving all the logic necessary for the rendering engine 204 to be able to render an instance document, the processing engine 202 may modify a document object model (DOM) representation of the source XML document 208, for example, by physically including XML fragments to which the source XML document 208 refers.
After the processing engine 202 has resolved all the logic necessary for the rendering engine 204 to be able to render the instance document in a form suitable for viewing by humans, the rendering engine 204 transforms the source XML document (as modified by the processing engine 202), omitting elements subject to an inclusion condition found to be false, and including responses to questions where appropriate into the desired instance format. Initially, the rendering engine 204 generates an HTML rendering of the instance document that includes controls for further processing of the document. Once an instance document has been finalised, the rendering engine 204 is used to generate a final rendering of the instance document, as described below.
It will be apparent that in order to generate an instance document in the format requested by the user (other than XML), it is not necessary to first generate an instance document in XML that is valid with respect to the same grammar as the source XML document. For desired instance formats other than XML (XML that is valid against the same grammar as the source XML document), the source XML document (as modified by the processing engine 202) is transformed by the rendering engine 204 into the desired instance format via several intermediate XML formats. During the course of those transformations, the processing instructions are replaced as appropriate with the information obtained during the interview process.
In an alternative embodiment, the processing engine 202 generates an instance XML document (using the same grammar as the source document or a similar one) for the rendering engine 204. In yet a further alternative embodiment, the generation of that instance XML document is an early step performed by the rendering engine 204 in the course of generating the instance document in the format desired by the user.
Source documents 208 and logic sources 210 are created and maintained using the editor 112, as shown in
The validation module 306 provides standard XML document validation, as well as logic source validation, and validation of interactions between source XML documents 208 and logic sources 210. The logic module 308 allows the user to define and manipulate questions, conditions and reusable text. It also allows the user to define parameter values that are used to determine default answer to questions, as described below. The editor 112 allows a user to define and manipulate logic within the logic sources 210, manipulate XML documents 208, and add logic references to a logic source 210 within an XML document 208. The editor 112 parses XML elements using the XML parser 206. The editor 112 uses the document grammars 212 and logic grammars 214 to determine which elements can be added and deleted, and how they can be manipulated. Grammars are also used as a basis for determining what types of logic can be added. For example, reusable text can only be added to elements that are allowed to contain text.
The processing engine 202 is coded in the object-oriented programming language Java. The Java language specification defines the notion of a package. As shown in
The evaluable node package 404 contains classes that represent a Condition and the various elements that are allowed within a Condition (e.g., And, Or, Not, Test and UseCondition). Each of these implement an interface called EvaluableNode. That interface defines an evaluate method that can be invoked in order to determine whether the value of the evaluable node is true or false.
The parties package 406 contains a class that represents a Party “known” to the source document, a Parties class that represents all known parties, and a class that represents a PartyDetail.
The interview items package 408 contains classes that represent the questions which the evaluator module 402 has encountered, and any responses that may have been provided or, for non-“key” questions, generated automatically. These include MultipleChoiceQuestions referred to in a Test, UserTextQuestions, and interview items encountered in an ArrayRowIterator.
The logic sources package 410 represents each logic source used directly or indirectly by the source document, and their contents, so that when a reference to a piece of logic is encountered, the logic can be retrieved efficiently.
The evaluator module 402 is the collection of classes that orchestrate the evaluation of the source document. It controls the evaluation processing, represents the state of the evaluation and calls the packages described above as necessary.
The rendering engine 204 includes an XSLT module which is used for transforming XML documents, a collection of XSL transformations, and several Xalan extensions which are used to manipulate objects referenced by the processing engine 202's evaluator module. XSLT and Xalan are available and documented at http://xml.apache.org/xalan-j/.
The processing engine 202 begins processing an input XML document 208 when its invocation API is called by an invoking process 412. In the preferred embodiment, the invoking process 412 is the Java controller servlet 218 which invokes the processing engine 202 in response to a request from the user's web browser passed to it from the HTTPD servlet container 216. However, the processing engine 202 can alternatively respond to requests from other applications or a Web service.
The invoking process 412 asks the evaluator module 402 to evaluate the source document. While there are interview items for which the evaluator module 402 currently needs a response, the evaluator module 402 returns those interview items to the invoking process 412. It is the responsibility of the invoking process 412 to obtain a response for each of those interview items via some InterviewItem Resolution Mechanism 414. In the preferred embodiment, the Interview Item Resolution Mechanism usually renders those interview items as inputs on an HTML form sent to the user's web browser, although in some cases it resolves the interview item in some other way, for example via a query to a database, or by invoking a web service. In such cases, an Other Sources module 416 provides an interface to data sources such as databases, file systems, web services, directory services, and so on. The invoking process 412 then passes the interview items, together with their responses, back to the evaluator module 402.
As described above, the interview rounds are used to determine values for variables used by the source document and/or referenced logic sources, and these variables determine content of the resulting instance document. In the general case, where some or all variables are resolved from data sources other than a user, the variables are resolved at step 506, as described below, until the system is able to generate an instance document.
Variables that can be resolved without user input are resolved by the processing engine 202 from other data sources. The processing engine 202 provides the questions to which it requires responses to the Java controller servlet 218. It is the responsibility of that servlet 218 to return the responses to the processing engine 202. Where the questions are put to a user via their web browser, the controller servlet 218 can put all the questions to the user in a single HTML form, or it can put the questions to the user one at a time, or it can group them by topic, asking the questions in a single topic in a given form.
In response to the user selecting a button 608 labelled “next”, the processing engine 202 determines, at step 506, whether there are further questions. If there are no further questions, the rendering engine 204 generates at step 510 an instance document in HTML format on the basis of responses provided by the user, and the instance document is then displayed by the web browser, as shown in
The parts of the text that are dependent on answers provided by the user are provided as hypertext anchors 702, allowing the user to view the questions and responses that resulted in the insertion of that text in a popup window 704 by moving their mouse over the text. If, at step 512, the user selects the hypertext anchor 702, the processing engine 202 generates a new interview round including the relevant question, allowing the user to provide a different response to that question. Questions dependent on the new response are then presented to the user at step 506 until the processing engine 202 determines that all the necessary information has been provided. A new HTML rendering of the instance XML document is then generated at step 510 and displayed by the web browser.
When the user is satisfied with the instance document, one of a number of buttons included near the top of the HTML instance document can be selected to generate an output document. The button selected determines the format of the output format. For example,
Controls 712 are also provided for storing responses on the system as stored response data 215 and for applying stored responses to the source document they came from, or to another source document that uses some of the same logic sources, and for processing groups of related documents.
It is useful to be able to store the response data, so that if a user wishes to modify some of the answers they have given in an earlier session, they can start by applying the stored response data to the source document, rather than having to answer all the questions again themselves. When an answer file containing stored response data is loaded, the questions and answers are displayed to the user in an HTML form. After the user has modified the responses as appropriate, and submitted the form (by selecting a “next” button), those interview items are provided to the evaluator module 402. When, in the course of evaluating the source document to which those answers are being applied, an interview item is encountered, there will be no need to ask the Java controller servlet 218 for a response to that item, if the response has already been provided via the answer file mechanism.
In a similar way, the Java controller servlet 218 can invoke the processing engine 202, applying a collection of response data to the several source documents comprising a group of related documents, and then invoke the rendering engine 204 to display the resulting instance documents in the user's browser, or save them to disk. It will be apparent that whether each document is processed then rendered, or all documents are processed then all rendered, depends on the controller servlet implementation (i.e., how it invokes the processing engine 202 and the rendering engine 204).
Thus the document assembly system provides an efficient, yet flexible means to generate and modify instance documents for different circumstances. The source documents 208, document grammars 212, logic sources 210 and logic grammars 214 are typically created and maintained by an administrator of the system in accordance with the needs of the system's users. For example, a legal firm will create precedents for particular circumstances, e.g., contracts, as source documents 208, together with their associated logic sources 210 and grammars 212, 214. The creation and maintenance of these files 110 is performed using the editor 112. The actual assembly of these files 110 into instance documents is initiated by end-users of the system accessing the system using a web browser.
The document assembly system is described in more detail below with reference to examples of the data files 110 used by the system. An XML source document used by the document assembly system for generating instance letters is presented below in its entirety. Portions of this source document are then described in detail to illustrate various features of the document assembly system.
This source document includes several processing instructions (PIs) that begin with “<?SpeedLegal” and end with “?>”. The data within the processing instruction, i.e., between these two strings, resembles one or more XML elements. This allows an application to receive the data and parse it as XML, with the various benefits which that entails. It will be apparent to the skilled addressee that this structure is in conflict with the XSLT 1.0 specification, which specifically prohibits an XSLT processor from constructing PI data in this form. In what follows, it is convenient to refer to the PI data as if it were an XML element.
Some of the PIs in the above source document include within them a LogicSource XML element whose purpose is to specify the location or locations, outside of the source XML document itself, where the system can find the material necessary to process other processing instructions encountered within the document, such as the Condition instruction in the above example. For example, a logic source is identified in the above example as follows:
The LogicSource sub-element of the LogicSources element specifies a universal resource indicator (URI) at which the corresponding logic source can be found, and assigns an ID reference name to it. Many of the processing instructions throughout the example source document above contain an IDREF reference to one of the ID reference names of the listed logic sources, which is used to identify the URI of the corresponding logic source. Thus the first logic source referred to in the XML document is located at the URI “/files/logic/LS1WD.lgc” and is referred to at other places in the source document by the ID reference “LogicSource—1”. This logic source is provided below.
Because the information necessary to process processing instructions encountered within the source document are stored outside the source document, this information can be stored in an XML format and can therefore be validated against an XML schema or DTD. The DTD used by the document assembly system for validating logic sources 210 is as follows:
Another advantage of separating logic source files 210 from document source files 208 is that the logic source files 210 can also be re-used in conjunction with other XML documents, simplifying maintenance. For similar reasons, it is convenient to store logic information in separate files rather than, for example, one monolithic logic file. This allows related information to be grouped together, and only the logic components that are required need to be re-used with a given source document.
It will be apparent that this information could alternatively be stored in a database rather than separate XML files. Separate XML files are preferred because they can be easily arranged in a hierarchical file system. However, if a logic source which is in use is moved, then a base XML document that refers to the logic source will include an incorrect URI, and will need to be updated. In an alternative embodiment, the repository 208 in which the source documents are stored detects the fact that the logic source has been moved, and updates the references to that logic source automatically, or alternatively, advises a URI resolver (the purpose of which is to translate old locations to actual locations) of the new location. This approach can be implemented with file systems that allow extra code to be executed automatically when a file is moved, renamed or deleted. Many WebDAV server implementations are provided with source code, which would enable a document assembly system which used a webDAV server as its repository 208 to implement this.
In yet a further alternative embodiment, the document assembly system includes a single resource that authoritatively associates the name of a logic source with its location, so that in a reference to a logic source, a source document includes the name of the resource known to the system (together with the party mapping being used, as to which see further below). In this embodiment, only that single resource needs to be updated when a logic source is moved or renamed.
A logic source can refer to one or more other logic sources. For example,
Assembled documents often refer to one or more parties. For example, a legal document might refer to the parties involved in an agreement of some kind. In such cases there are often only two parties involved, but in some circumstances there may be many parties. A logic source specifies the parties known to it, in its PartiesSetup element.
A party mapping is a child on a logic source import that allows parties used in a logic source to be mapped to parties used in a document importing the logic source. This makes it possible for a logic source which, for example, refers to a Plumber and a Homeowner, to be used in a document between a Banker and a Customer.
A party mapping chain is a chain of party mappings between a base XML document and a logic source. It will be evident that a party mapping chain can swap two parties around e.g., if the LogicSource import statement in the base XML document 812 for the first logic source 802 said, in effect, “Employer becomes Employee and Employee becomes Employer”. Thus two references to the same physical logic source are regarded as logically the same if and only if their respective party mapping chains result in the same party mapping.
It is not an error to import the same logic source twice in a single LogicSources statement (allocating each occurrence a distinct ID). This allows one physical question or condition to be used for two logical questions by defining different party mappings in each LogicSource import statement.
In addition to those described above, the example source document and logic source above include seven other types of processing instruction:
For half of these, there is a correspondence between a processing instruction in a source XML document and an element in a referenced logic source. That is, when software manipulates or interprets the processing instruction, it does so in conjunction with the corresponding element in the logic source. This correspondence is as follows:
ArrayRowIterator, SmartModule, Notes and MetaInformation are exceptions to this—an ArrayRowIterator is independent, as is Notes and MetaInformation, while a SmartModule has a correspondence with a fragment of XML stored at some other URI.
A Condition processing instruction specifies by convention that its parent element should only be included in the instance document if the associated condition evaluates to true. For example, the following condition is taken from the example source document given above.
This means that the <p> element will only be included in an instance document generated from this source document if the Condition AmountOfLeave.negotiate in the logic source named “LogicSource—1” is true. It will be apparent that alternative embodiments could be developed to implement the condition is other ways. For example, the Condition could by convention apply to the following sibling, or Condition open and Condition close processing instructions could be used to surround the XML to which the condition is to apply. However, neither of these approaches is preferred. In the first case, there may be no following sibling. In the second case, if the open and close processing instructions are not properly nested so that they precede and follow, respectively, a matching pair of tags, then the resulting instance document would not be well-formed. Similarly, the syntax of the Condition PI could have been written in various ways, some of which include data that looks like XML, and others that do not, including:
However, the first of these is the form used in the preferred embodiment.
The IDREF attribute of a condition PI specifies the ID of the condition to be tested; the LogicSource attribute is an IDREF to the logic source in which the condition is defined. For example, the logic source file with an IDREF of “LogicSource—1” and listed above contains the definition of the AmountOfLeave.negotiate condition, as follows:
This means that the condition will evaluate to true if the response given for the question named (i.e., with an IDREF equal to) “AmountOfLeave” has the value “negotiate”. The question “AmountOfLeave” is a multiple choice question defined in the logic source, as follows:
In this example, the MultipleChoiceQuestion element's QuestionType child has value “false” for attribute KeyQuestion. This means that the processing engine 202 is free to attempt to answer this question itself (i.e., without interacting with any external agent) using its scoring procedure if the user or software invoking the Processing Engine 202 indicated they only wished to be asked Key Questions.
If the SelectionRules element has value “Bias” for the AnswerUsing attribute, as is the case here, then the processing engine 202 scores each response based on the values contained in its SelectionCriteria child and which party the user or software invoking the Processing Engine 202 indicated they wish to favour. Alternatively, if the SelectionRules element has value “Default” for the AnswerUsing attribute, then the processing engine 202 selects the response for which the SelectionCriteria element's “Default” attribute has value “Checked”. For example,
In the above example, the MultipleChoiceQuestion is defined in the logic source that also defines the condition. However, a definition in a different logic source can be used, assuming that different logic source was declared in the LogicSources element (of the logic source which defines the condition), by including its IDREF name (i.e., the name assigned to it in the logic sources element) in the Test element, for example:
A condition can be defined in terms of other conditions, using boolean logic operators. In the example, the Condition PaidLeave is defined as follows:
This condition will be true if either the condition Employment_type.FullTime is true or the condition Employment_type.PartTime is true.
It will be evident that condition PIs as described above can only be attached to elements. The question arises—what if it is desired to attach a condition to some text which is not tagged (or it is not desired to tag, or, because of the grammar, cannot be tagged) with an element to which a condition can be attached. There are several possible solutions to this. One possibility is to define opening and closing Condition PIs that surround the text in question. However, this approach has drawbacks already adverted to above. In the preferred embodiment, the text is defined in a logic source, and an “InsertReusablePhrase” processing instruction is used to refer to it in the source document.
There is an InsertReusablePhrase in the example XML document above:
The corresponding ReusablePhrase with ID “PaidOrUnpaidLeave” is defined in the logic source as follows:
Thus a ReusablePhrase can contain not only text, but other things which are evaluated. One of these is a “ConditionalPhrase”. This is an element which is defined in the logic source schema or DTD, mainly for the purpose of allowing a condition to be attached. In this way a ReusablePhrase can be used to conditionally insert text into the XML document in the absence of an element to which a condition can otherwise be attached. In alternative embodiments, a condition could be attached directly to the ReusablePhrase element as an attribute, or a new processing instruction defined which specifies both a condition and the text to be inserted if the condition is true.
Information entered by a user in response to a question can also be inserted into an instance document. For example, suppose that the source document listed above included the following processing instruction:
The rendering engine 204 processes this instruction by inserting, in the instance document, the value (i.e., the response provided by the user) of the user text question with ID “LetterSubject” that is defined in the logic source “LogicSource—1”.
That user text question is defined in the logic source as follows:
The type attribute restricts the allowed type of input to the specified format, which is one of text, duration, time, date, decimal, or integer. In this example, the user can enter free text.
In an alternative embodiment, users are given greater flexibility to define and use their own variable types. This gives the user the ability to validate a broader and more complex range of data types than is possible with a closed set. For example, a UserTextQuestion can be assigned a defined data type as follows:
More generally, a Variable has an assigned data type, as follows:
The data types are defined either in the logic file:
This data typing relies on XML Schema simple types, as described at http://www.w3.org/TR/xmlschema-2/.
The documentation element of the simpleType is used to provide explanatory text to the user during the authoring and interview stages. Document authors are provided with a list of available data types. Once a Variable is assigned a type, the Query that populates it returns content of the required type. If the Query results in an Interview Item, the user inputs data of the required type. If the input data is not of the required type, then the user is provided with feedback using the documentation element, and is informed as to what data-type is expected. The Interview Item is then re-answered.
During the authoring process, the documentation element can be used to indicate to an author what each data type is intended to represent.
The appinfo element of a simpleType can be used to perform customised checking in addition to schema type checking. In the example above, SimpleDate is a custom date format. A value of this type is validated in two phases. It is first checked to be a string according to the normal schema validation rules, identified as such via the restriction element. Secondly, it is checked using a separate more specific validation function identified by the appinfo element.
Interview Item responses are type-checked using schema data type validation functions. These are available in libraries such as Sun's XML Data Types Library (xsdlib), available at http://wwws.sun.com/software/xml/developers/xsdlib2/. These functions can also be used within the authoring environment to check the type of default values.
In the preferred embodiment, MultipleChoiceQuestion and UserTextQuestion are distinct elements, even though their content shares some common characteristics (e.g., a question). In an alternative embodiment, the common characteristics are abstracted out in the DTD, (or, alternatively, schema) as follows:
Indeed, the InterviewItems package 408 of the Processing Engine 202 of the preferred embodiment uses an abstract class called InterviewItem that captures the commonalities between MultipleChoiceQuestion, UserTextQuestion, etc, with subclasses that represent the specifics of each case.
Moreover, although UserTextQuestion is implemented with a type attribute in the preferred embodiment, the different types could alternatively be implemented as elements in their own right, in which case the InterviewItem element declaration might look like:
A party reference processing instruction is used by the processing engine 202 to generate text referring to a party. For example, the following:
It can be seen from this example that the PartyDetail can contain values for different Gender and Number. Assuming the Gender and Number of the party has been ascertained (in this embodiment a question to do so is automatically generated by the processing engine 202 when required), the corresponding value can be evaluated by the Processing Engine 202, and inserted by the Rendering Engine 204, as described below.
It will be evident that other attributes could be included on the PartyDetail Value children, for example, “Formal”, which would be useful with some languages other than English.
The example document contains a processing instruction specifying an ArrayRowIterator:
If an XML element has an ArrayRowIterator child, then that element (<tr> in this example) will be copied into the instance document one or more times. When the source document is processed by the Processing Engine 202, the processing engine 202 determines how many times that element is to be included in the instance document. To determine this, it uses a “repeat” attribute. If the value of the repeat attribute is a positive integer, then the element is included that many times. Otherwise, the value of the repeat attribute is the name of an interview item that can only take an integer response (preferably, any limit on the range is specified in that interview item).
For each time it is copied in, a distinct value is required for each Interview Item referred to in an ArrayReference processing instruction. For example, if the value of the repeat attribute was 2, then the first time the <tr> element appeared (e.g., the first row), the UserTextQuestion “LeaveType” might have value “Annual Leave”; and the second time (e.g., the second row), “Maternity Leave”.
The InterviewItems package 408 contains a class that represents an ArrayRowIterator. The ArrayRowIterator class contains a collections object which contains UserTextQuestions and MultipleChoiceQuestions for each row. When the ArrayRowIterator is passed to the invoking process 412 to be answered, the UserTextQuestions and MultipleChoiceQuestions contained within it are asked as necessary.
In the preferred embodiment, there is no corresponding element in any logic source for an ArrayRowIterator processing instruction. In other words, nothing is needed in any of the logic sources (beyond ordinary Interview Items e.g., MultipleChoiceQuestions and UserTextQuestions) which are referenced by the ArrayReference processing instructions).
It is often desirable to use an Interview Item, within an element that has an ArrayRowIterator child, that takes the same value each time the element is repeated (in other words, such an Interview Item does not get asked for each row).
Consequently, the preferred embodiment uses the same value each time unless an ArrayReference processing instruction is provided. The ArrayReference processing instruction specifies that the corresponding item is to be treated as an array of questions (e.g., asked again for each row), rather than assuming this for any interview item that occurs within an element with an ArrayRowIterator child. If that assumption were valid, then there would not be any need for an ArrayReference processing instruction.
An alternative embodiment which did not make this assumption but also did not use an ArrayReference processing instruction might include an attribute on each Interview Item which indicated whether in an array the interview item was asked just once, or once each array iteration. For example, that attribute might be named ArrayRowIteratorBehavior with allowed values “variant” or “invariant”, and appear on the Question child of a UserTextQuestion or MultipleChoiceQuestion.
A SmartModule processing instruction is used in a source document to indicate that a fragment of XML at a specified URI is to be retrieved when the source document is run through the processing engine 202. For example, the following is taken from the example source document:
The PartyMapping is used to translate PartyReferences in the XML fragment referenced by the SmartModule PI to references to party details on parties that are known to the source XML document. For example, consider a base or main XML document 812 that refers to parties P1, P2, and E, as shown in
Referencing and party mapping can be nested. In order for the main XML document 812 to make use of the logic contained in the second logic source 804 and the third logic source 806, the main document 812 includes party mapping instructions to map parties A and B of the second logic source 804 to parties P1 and P2, respectively. For the third logic source 806, parties C and D are mapped to parties P1 and P2, respectively; because there is no mapping for party E, it becomes “known” to the main XML document). However, because the third logic source 806 contains a reference to the fourth logic source 808, the logic imported from the fourth logic source 808 effectively undergoes two levels of party mapping, referred to as a party mapping chain. That is, references to parties M and N in logic from the fourth logic source 808 that were already mapped to C and D as described above are now mapped again, in this case to parties P1 and P2, respectively, when imported into the main XML document 812.
If a single logic source is used more than once (e.g., it is used in different logic sources, in which case, in the example in
As shown in
A Notes processing instruction is used to present one or more notes to a user, via their browser display and/or in a printed document. For example:
The CompletionInstruction attribute indicates whether the note provides information as to how the document should be completed; the ShowExternalUsers and UserLevel attributes allow the note to be shown or not shown, depending on whether the user matches the specified criteria. UserLevels can be defined arbitrarily. A user is defined to be external for the purposes of ShowExternalUsers if, in a role-based access control system, the user is in an external role (i.e., external to the organisation running the document assembly system). Notes can also be attached to a question or a response of a UserTextQuestion or a MultipleChoiceQuestion in a logic source.
The MetaInformation processing instruction allows meta-information to be attached to an element in a source document. There is also a MetaInformation element defined in the grammar for a Logic Source. In this embodiment, that definition uses concepts provided by RDF and Dublin Core, as described at http://www.w3.org/TR/REC-rdf-syntax and http://dublincore.org/schemas/xmls/, respectively. The format of the MetaInformation PI data is the same as the definition of the MetaInformation element in the Logic Source grammar.
Most of the examples presented above demonstrate the resolution of MutipleChoiceQuestions and UserTextQuestions by presenting a question to an end user and receiving a response to that question from the end user. In an alternative embodiment, where UserTextQuestions, ReusablePhrases, Conditions and ArrayRowIterators (Repeats) are viewed as specific instances of a general class of constructs named Variables, a LogicFile can be constructed such that Variables are able to be resolved from other sources (Queries).
Consider the following LogicFile elements:
In the fragment above, five Variables or differing types are defined and their values are obtained from various sources, as listed in the Table below.
In this embodiment, a UserTextQuestion is an Interview Item Query that is used to populate a Variable of any data type. A Condition is a Variable of fixed type (boolean) that obtains a true or false value from a Query. Repeats or ArrayRowIterators are Variables of fixed type (integer zero or greater—nonNegativeInteger) where the value is obtained from a Query. A Variable is a general element of any type that obtains its value from a defined Query. ReusablePhrases are collections of arbitrary Conditional text, PartyReference and InsertUserText elements defined within the logic file that allow users to conveniently define reusable objects. A Query is an element that populates one or more Variables (Answers) by taking in zero or more Parameters (other Variables). Queries encompass:
A Query contains references to the Variables or Answers that it populates. A single Query can potentially resolve many Variables. This is especially useful for database sources where one lookup can return many fields of data. A Variable may also reference its resolving Query for convenience. A Query implementation may contain a default value that is used when the Query fails. Queries may fail for a variety of reasons including inaccessibility, recursive or looping queries, incorrect syntax, and incorrect setup.
Failure mechanisms can be defined such as:
It should be noted that the LogicFile structure depicted above decouples the declaration of the Variable from information about where and how it is resolved.
Variables can be referenced within an XML document as follows:
The StartDate variable, which is defined in the LogicFile example above as a SimpleDate, is inserted into the document via an InsertUserText processing instruction.
The XML document example above also demonstrates how versioning is implemented in this alternative embodiment. There is a “version” attribute on the LogicSource element indicating that this document requires a particular version of the logic resource identified by the “uri” attribute. This method for identifying resources and versions of resources is consistent with the DeltaV standard for version control, as described at http://www.webdav.org/deltav/. The “version” attribute is also present on the SmartModule.
Versioning offers a number of advantages to the system, including the ability to incrementally change, rollback and record differences between versions of a document. When a new version is created, the author is prompted to supply information relating to the changes made. If a more recent version of a LogicSource or a Module is available, a user can update to the newer version of the resource (if compatible). Compatibility is determined by checking that all references in the document to the old version will be resolved by the new version. This creates the possibility for LogicSources and Modules to be maintained independently of documents that refer to them. Versioning avoids the possibility of logical inconsistencies. These can occur where a shared LogicSource is modified such that not all Variables can be resolved. Since a given document can only ever point to a particular version of a LogicSource or Module, this is never possible. Finally, versioning creates the option for ‘publishing’ a particular version of a document to users while the document continues to be developed. Some users may be restricted to only being able to access these ‘published’ or approved documents.
A standard XML editor designed purely for editing XML documents only needs to concern itself with the document grammar, the user interface, and the XML document. In contrast, the editor 112 of the document assembly system performs standard editing functions but also:
As shown in
A prompt text box 1510 is provided for editing each possible response (as it will be presented to the user) to this multiple choice question. Value text boxes 1512 allow the user to enter a variable value associated with each response. For example, if the award entitlements response was selected by a user, the MultipleChoiceQuestion or variable AmountOfLeave would have value “award”, and the related conditions AmountOfLeave.award and AmountOfLeave.negotiate would have a values of true and false respectively. “Add notes” buttons 1514 are provided for each response, allowing the user to add note text which can be displayed during the corresponding interview to assist a user to select the appropriate response.
Within the editor 112, the user may also need to be able to reuse a chunk of XML with its associated logic. A reusable chunk of XML is referred to as a Module.
A Module comprises:
To make a Module available for re-use, the editor 112:
There are two ways that a user may desire the module to be used. In the first, a copy of the module is imported into the document—this allows the author to modify the text and/or logic as the module now forms part of the target document. For a module copy, the editor 112:
Alternatively, the user can import into the document a link to the module—this can point to a current version of the module, and any modifications subsequently made to the module are automatically reflected in the resulting document. For a module link, the editor 112:
In some circumstances, it may be desirable to ensure that an instance XML document can be generated which conforms to the same grammar as the source document, for example, if the XML instance document is to be used outside the document assembly system (for example, edited in a standard XML editor).
If it is possible to place conditions on any element in the source XML document, then there is no guarantee that the instance XML document will be valid.
As an example, suppose the DTD (xhtml-letter-v2) used for the letter document above specified that a <letter> must have one and only one <LetterHead> child. Then, if a user were able to place a condition on the LetterHead, and in processing the source document through the Processing Module 202 that condition evaluated to false, the <LetterHead> child would be omitted from the instance XML document, with the result that the instance XML document would be invalid.
XML grammars can express a variety of restrictions on the number of occurrences that are allowed for particular elements, for example zero or one, exactly once, and one or more times. If an instance document does not match a specified rule, it will be invalid.
To ensure that the instance XML document is valid, a condition PI can only be attached to an element if:
In order to express more than one alternative for an element that is only allowed to occur zero or one times, one condition is applied to the element itself to determine whether the element appears at all in the instance XML document, and alternative condition PIs are applied to nodes inside the element (the same rules apply to the use of conditions on these nodes). If an element is to occur exactly once, and it is desired to allow several possibilities for its textual content, then conditional phrases are used inside the element—the editor 112 prevents a condition from being attached to the element itself.
Similarly, if an XML document contains an element with an ID, and another with an IDREF which points to it, then, if the element with the ID had a condition on it which evaluated to false, with the result that that element was not included in the instance XML document, and the element with the IDREF was included, the document would be invalid.
Accordingly, if the instance XML document is to be valid, then any element with an attribute of type IDREF is subject to conditions that include all the conditions to which the element with the corresponding ID is subject. Whenever the conditions to which an element with an ID is subject are altered, the editor 112 ensures that all elements with an IDREF pointing to it are subject to appropriate conditions.
After a source document 208 and its one or more logic sources 210 have been defined with the editor 112, they can be used by the processing engine 202 to generate one or more instance documents. The processing engine 202 begins processing an input XML document 208 when the Java controller servlet 218 creates an instance of the evaluator 402 in response to a request from the user's web browser. In the preferred embodiment, the constructor for the evaluator 402 takes the input XML document as a document object model (DOM) object, but it could alternatively be passed as text, or as a URI from which it can be retrieved.
Later, the Evaluator 402, in conjunction with the evaluable node package 404 and the parties package 406, identifies questions that need to be answered. In order for it to be able to suggest a default answer or answers for each question which would result in text intended to favour one party to the document over another (or to automatically answer a question that is not a KeyQuestion), the Java servlet 218 may specify to the Evaluator 402 which party to favour, as ascertained at step 504.
The Evaluator 402 constructs two objects it will need later: operativeConditions, and operativeInterviewItems. It also extracts the logic from each logic source referred to in the document's LogicSources element, and from each logic source referred to in the LogicSources elements in each logic source, and so on (being careful not to get into an infinite loop). However, in the preferred embodiment, the Evaluator 402 does not extract the logic from a logic source imported by an XML fragment until the SmartModule processing instruction is encountered later. When the logic import is performed, the Evaluator 402 determines how the parties in that logic source are mapped, relative to the main XML document (the party mapping chain). Each Condition and InterviewItem (e.g., MultipleChoiceQuestion and UserTextQuestion—there are no ArrayRowIterators in a logic source) is stored in a hash table keyed by the URI of its logic file combined with its party mapping chain and its own ID, so that discrete instances (as explained above) can be stored, and they can be retrieved efficiently.
Finally, the Evaluator 402 extracts Party declarations from these logic sources, creates a Party object to represent the Party declaration, and stores each Party object in the Parties object of the party package 406, keyed by the URI of its logic file combined with the ID of the Party. Each Party object has objects associated with it representing each PartyDetail, and each PartyDetail has a means of representing each Value in it. The Value element is stored in an object named PartyDetailValue.
The invoking process (the Java Controller Servlet 218) then calls evaluator.initialisePartiesInUse( ). The purpose of this method is firstly, to identify any UserTextQuestions in a Party XML object that will definitely need to be answered (i.e., irrespective of whether any conditions in the document evaluate to true or false), and secondly, to identify the Party XML objects for which the engine will need to know a gender and/or number. It is desirable to establish this up front, so that for an invoking process 412 which interacts with an end-user, the questions relating to the parties can be put to the user before the other questions. One of the benefits of doing this is that words in those other questions that identify a party by using a PartyReference can be replaced with the value of that PartyReference.
The method evaluator.initialisePartiesInUse( ) performs a breadth-first traversal of the DOM object. The breadth-first traversal is implemented recursively; recursion stops at any node that has a condition attached to it. Where in the course of performing the breadth-first traversal, a PartyReference PI is encountered, getValue is invoked on the appropriate PartyDetail. That method is as follows:
Where necessary, by invoking other methods, getValue causes InterviewItems to be created which represent the questions that need to be answered. The questions are either MultipleChoiceQuestions that seek to establish the Gender (Male, Female or Neuter) or Number (Singular or Plural) of a Party, or UserTextQuestions that prompt for text forming part of the value of the PartyDetail for the matching Gender and Number (where ‘matching’ is determined by the procedure implemented by the getValue method).
When the Evaluator 402 has finished doing this, the invoking process 412 checks to see whether there are any InterviewItems that need to be resolved. If there are no InterviewItems that need to be resolved, Evaluator.evaluate( ) is invoked. It extracts any InterviewItems from the document which need to be resolved at this point. Its function is described in detail below.
If there are still no interview items that need to be resolved, then the input document is a trivial case, and the instance XML document would be identical. Otherwise, the invoking process 412 resolves the interview items.
The Java controller servlet 218 creates an HTML form for a user to complete in their web browser. However, it will be apparent that the controller servlet 218 could alternatively seek responses from some other source, for example, a database which it queries using SQL, a web service, or some application using its API. As described above, a logic source can specify a preferred method for resolving either all interview items, or some particular interview item, together with the details required in order to do so (e.g., URL, authentication information, query etc) which the invoking process 412 attempts to honour. The invoking process 412 returns a response for each interview item, even if it couldn't get a response using the preferred method.
Having resolved the interview items, the invoking process 412 calls Evaluator 402's evaluate( ) method, passing it a set of interview items that contain values. evaluate( ) first transfers the answers from the interview items proffered by the invoking process 412 to any matching interview items for which it was awaiting responses. Because there is a flag on each PartyDetail and each Condition object which ensures that the Evaluator 402 only attempts to evaluate it once each time the invoking process 412 calls Evaluator 402's evaluate( ) method (hereinafter called “interview round”), these flags are reset.
As described above, the Evaluator 402 performs a recursive breadth-first traversal of the DOM object. During the course of the breadth-first traversal, certain nodes will be encountered that require special handling. In this embodiment, these nodes are all processing instructions so that they can be included in an XML document without affecting its validity.
PartyReference processing instructions are treated as described above. It is possible for the Evaluator 402 to encounter a PartyReference to a PartyDetail not previously encountered (because it occurs below an element to which a condition is attached). As before, getValue is invoked on the appropriate PartyDetail.
It will be apparent that in embodiments of the present invention, any node could be given special handling—either by node name, or node type, in either all documents or only documents using a specified XML schema or DTD, or indeed by position in the document. In the preferred embodiment, the traversal method calls an empty method which can be overridden in a subclass of Evaluator to implement this special handling if desired.
When a node that has a condition processing instruction is encountered, the Evaluator 402 attempts to evaluate it. First, it looks to see whether that condition has been encountered already (if it has, an object representing it will be stored in the operativeConditions object). If the condition has not been encountered already, an object that represents it will be constructed and stored in the operativeConditions object. Then, if the condition is not fully evaluated, and if the relevant flag indicates that no attempt has been made to evaluate the condition in this interview round, the Evaluator 402 attempts to evaluate the Condition.
The Condition is evaluated as follows. Each of the elements that can appear in a Condition—the operators And, Or, Not, Test, UseCondition, and the values True and False—implements an interface that defines a method named evaluate( ) (not to be confused with Evaluator 402 or its evaluate( ) method), and has a constructor with the same signature. Because of this, in this embodiment, the Condition object can use a Java programming technique known as reflection to construct objects representing its children, and call their evaluate( ) method. In turn, if a child of an object is And, Or, Not, Test, or UseCondition, the objects can recursively construct and call evaluate( ) on an object representing that child, so that ultimately, each of And, Or, and Not, has arguments that are boolean values that can be evaluated to true or false using classical boolean logic. Finally, Condition(True) evaluates to True, and Condition(False) evaluates to False.
If a Test node is encountered, then when its evaluate( ) method is invoked, the Test object checks to see whether the MultipleChoiceQuestion it refers to has been instantiated as an object (it will have been if some other Test node which refers to the same MultipleChoiceQuestion has already been processed). If the MultipleChoiceQuestion has not been instantiated, a MultipleChoiceQuestion object representing it is constructed.
If the invoking process 412 has indicated that only Key Questions should be asked, and this question is not a Key question, then the processing engine 202 can evaluate it automatically using the scoring procedure based around the SelectionRules and SelectionCriteria for that MultipleChoiceQuestion (in this embodiment, a method in the object representing the MultipleChoiceQuestion in the interview item package 408 does this). Where a new MultipleChoiceQuestion has been constructed, it will be added to operativeInterviewItems. Each InterviewItem (a MultipleChoiceQuestion is a type of InterviewItem) in operativeInterviewItems has status either “pending” or “known”.
If a MultipleChoiceQuestion has status pending, then the Evaluator 402 waits for the invoking process 412 to provide it with a response value before it evaluates the Test that uses it to true or false. InterviewItems with status pending are not returned to the invoking process 412 as they are created, but rather, are only returned when the traversal has been completed. This makes it easy for an invoking process 412 that interacts with a user to put several questions to the user at once, perhaps organised by the value of the MultipleChoiceQuestion's Topic child.
If the MultipleChoiceQuestion has status known, then Test's Evaluate method will return true if the MultipleChoiceQuestion has a response equal to the value specified in the Test, and false otherwise.
If the condition evaluates to true, then the traversal can descend into the node to which the condition applies. If it evaluates to false, that node will not be included in the instance XML document (To assist the rendering engine 204 later on, the evaluate method of the Evaluator 402 adds an attribute named “diedInEvaluation” to an element that had a condition which evaluated to false.). If the condition cannot be evaluated to either true or false, the traversal does not in this interview round descend into the node to which the condition applies. Instead, any pending interview items (created as described above) will in due course be returned to the invoking process 412 for resolution, so that, assuming responses are provided, the condition may be evaluated in the next interview round.
When an InsertReuseablePhrase processing instruction is encountered, the Evaluator 402 retrieves the ReusablePhrase node it refers to from the relevant logic source, and physically replaces the processing instruction node in the DOM object with that ReusablePhrase node. It then puts an IDREF to that logic source on relevant descendants of the ReusablePhrase node, and converts any logic elements in those descendants from the XML format used in the logic file to the Processing Instruction format appropriate to the XML source document. It is then possible to traverse the descendants of the ReuseablePhrase node in the usual way, albeit in a context provided by the party mapping chain for the logic source it came from (so Conditions and InterviewItems can be looked up correctly).
A consequence of this way of processing an InsertReuseablePhrase processing instruction is that a single ReusablePhrase node is inserted into the document and traversed multiple times if there is more than one InsertReusablePhrase processing instruction that points to it. In an alternative embodiment, each ReusablePhrase node could be traversed just once, and the result inserted into the document at a later step.
When an InsertUserText processing instruction is encountered, the Evaluator 402 determines whether a UserTextQuestion object representing the UserTextQuestion the processing instruction points to already exists in operativeInterviewItems. If it does not, the Evaluator 402 creates a new UserTextQuestion object, and adds it to operativeInterviewItems with status “pending”.
When an ArrayRowIterator element is encountered, the processing engine 202 first checks to see whether its “repeat” attribute has a known positive integer value. If it does not, then the ArrayRowIterator cannot be processed any further until the InterviewItem named in that attribute has a value (it is an error if that value is not a positive integer). Once the “repeat” attribute has a known positive integer value, a two-dimensional array of InterviewItems is created. The first dimension is the InterviewItems identified in the ArrayReference processing instruction descendants of the parent of the ArrayRowIterator; the second dimension is the number of rows specified by the “repeat” attribute. The ArrayRowIterator object containing that two-dimensional array of interview items is added to OperativeInterviewItems, and resolved in the usual way.
A situation can arise whereby two ArrayRowIterator processing instructions contain ArrayReference processing instructions pointing to the same interview item. For example, suppose a first ArrayRowIterator has a repeat attribute value of n1, and the second n2. In the preferred embodiment, the Interview Items in the abs(n2−n1) rows common to both ArrayRowIterators are then asked only once. However, alternative embodiments could require independent values for the InterviewItems in those rows.
When the breadth-first traversal is complete, the evaluate method of the Evaluator 402 returns control to the invoking process 412. The invoking process 412 then asks the Evaluator 402 for all operativeInterviewItems that have status pending. If there are none, then the document has been fully evaluated, and an instance document is created by the Rendering Engine 204. If there are operativeInterviewItems with status pending, the invoking process 412 determines a response value for each of those interview items, as described above following evaluator.initialisePartiesInUse( ).
Having resolved the interview items, the invoking process 412 calls evaluate method of Evaluator 402, passing it a set of interview items which contain values. This cycle repeats, until such time as there are no pending interview items.
When there are no pending interview items, an instance document in XML, PDF, RTF, HTML, or some other format, can be created from the DOM document object which the processing engine 202 has been manipulating.
As the rendering engine 204 creates an instance document, elements of the source XML document with conditions that evaluated to false (and therefore had an attribute named “diedInEvaluation”) are omitted, each InsertUserText processing instructions is replaced by the value of the corresponding UserTextQuestion, the ReusablePhrases have replaced the InsertReusablePhrase processing instructions, and so on. This is done using XSLT with Xalan extension functions, which get the values of UserTextQuestions and PartyReferences from the evaluator 402. In alternative embodiments, an extension function could look up the value of the condition, instead of relying on the presence or absence of the diedInEvaluation attribute. An alternative to using XSLT for most of the rendering engine's work would be to programmatically do another recursive traversal.
Of particular interest is the generation of an instance document into HTML format. The instance document can be rendered in such a way that any text that appears as a result of one or more conditions evaluating to true, or as a result of a response to a UserTextQuestion, is generated by the rendering engine 204 as a hypertext anchor. When that anchor is activated, the user interface displays the question and response that resulted in the anchor text being included, as described above. In the case of text that is subject to one or more conditions, it would be possible to display the questions associated with each condition. However, in the preferred embodiment, only the questions associated with the closest ancestor having a condition processing instruction are displayed.
When the anchor is activated, it is also possible to reset one or more of the questions associated with the condition (which means the condition should be re-evaluated, so that the question is asked again), or, in the case of a UserTextQuestion, to ask it again. Where a question associated with a condition is reset, any other condition which used that MultipleChoiceQuestion is also reset, as is any other condition which used that condition, and so on.
The HTML rendering of the document also typically provides a list of all the questions that were answered, together with the user's responses. If the user selects a question link, the Processing Engine 202 resets that question as described above.
Many modifications will be apparent to those skilled in the art without departing from the scope of the present invention as herein described with reference to the accompanying drawings.