All of the example .HTM files are simple HTML forms
that submit data to the XmlToWpp.ASP page. The ASP page pulls the information
submitted from the form and formats that information into an XML Query that is
then submitted to WebPublisher PRO. The ASP page then receives the XML
response from WebPublisher PRO and pulls information from that response
to notify the user of the success or failure of the update. The XmlToWpp.ASP
page contains functions for each of the edit-over-the-Web functions and can be
used as a model. |
||
There are three pieces of information displayed by the ASP page. The top of the
page displays the status of the update in HTML. The HTML text will notify the
user if the record insert succeeded or failed and the reason why the insert may
have failed. Below the text are two textarea boxes that display the raw XML
that is sent to WebPublisher PRO and the XML that WebPublisher PRO
returns in response to the XML insert. |
||
In the Getting Started section, creating the XML Query string was covered in a
generic fashion in the form of a JavaScript function for use in your ASP page.
This section covers the code that needs to be
written in the ASP page for adding records. The specific syntax for the
function buildng the query for creating a new record is: |
||
function buildWpQuery(){ strXmlInput = '<?xml version="1.0" ?>\n' + |
||
If any field being updated contains a validation list, you can specify an attribute on the AC tag of validation="VALUE", where VALUE can be one of update, override, or none. The default value is none and will reject the record if the term entered on the form is not on the list. For example: |
||
<AC validation="override">INSERT</AC> |
||
When setting the AC tag as such, this will allow the record to be saved, but the validation list will not be updated. | ||
There is also an attribute available for the AC tag for trimming any leading
whitespace from the field value in the form, which accepts values of Y and N. The default value is N and will not trim the leading whitespace. For example: |
||
<AC validation="override" trim="Y">INSERT</AC> |
||
Setting the trim attribute to Y will eliminate any whitespace from the
beginning of the field value. If the whitespace is needed, the trim
attribute should either be omitted or should be set to N. |
||
In addition to specifying the textbase name and the action to perform, in this
case INSERT, you can also use KeyFields to specify which fields will be returned in the XML returned by WebPublisher PRO. |
||
'<KeyFields>\n' + |
||
The Recordset element is the parent of one or more Record elements. The Record element is the parent element for all of the field value elements. WebPublisher PRO extracts all of the values between the tags within the
<Record></Record> tags and uses them for the field values in the
textbase. |
||
'<Recordset>'+ |
||
In the case of fields that do not have multiple entries, you can get the value
by requesting the query string as described in the
Getting Started. For example: |
||
'<Product-Name><![CDATA[' + Request.QueryString("Product-Name>") +
|
||
For fields with multiple entries, call the makeMultiple function described in Getting Started. For example: |
||
makeMultiple("Features","|") + |
||
Note that it is safe to call makeMultiple for all fields, whether or not they
can or do have multiple entries. When assembling the fields within the Record
element, you can concatenate the values returned by the function
calls with a +. For example: |
||
makeMultiple("Features","|") +
|
||
Lastly, close off all of the open XML element tags—record, recordset, and query and return the output to the calling page to populate the variable. |
||
strXmlInput += '</Record></Recordset></Query>';
|
||
There is an example of this function (buildWpQueryForInsert() ) in XmlToWpp.ASP. | See it in action |