Làm thế nào tự động điền một bảng HTML với dữ liệu XML?

Organisation or management of web site content, e. g. publishing, maintaining pages or automatic linking
  • G06F16/972Access to data in other repository systems, e. g. legacy data or dynamic Web page generation
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e. g. TELEGRAPHIC COMMUNICATION
    • H04L69/00Network arrangements, protocols or services independent of the application payload and not provided for in the other groups of this subclass
    • H04L69/30Definitions, standards or architectural aspects of layered protocol stacks
    • H04L69/32Architecture of open systems interconnection [OSI] 7-layer type protocol stacks, e. g. the interfaces between the data link level and the physical level
    • H04L69/322Intralayer communication protocols among peer entities or protocol data unit [PDU] definitions
    • H04L69/329Intralayer communication protocols among peer entities or protocol data unit [PDU] definitions in the application layer [OSI layer 7]
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y10TECHNICAL SUBJECTS COVERED BY FORMER USPC
    • Y10STECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y10S707/00Data processing. database and file management or data structures
    • Y10S707/99941Database schema or data structure
    • Y10S707/99944Object-oriented database structure
  • Abstract

    A method operative at a server in response to a client browser request for generating a table having dynamic data. The method begins by instantiating a table format object with dynamic data extracted from one of a set of data objects through a common interface. The common interface enables page developers to author customized data getter objects that are used to access data in the set of data objects. The dynamic data extracted from the given data object through the common interface is formatted into the table according to the table format object. The resulting table with dynamic data is then served back to the requesting client browser

    Description

    CROSS-REFERENCE TO RELATED APPLICATIONS

    The present application is related to the following copending U. S. patent applications Ser. No. 09/455,710, entitled “CONDITIONAL HIGHLIGHTING OF GIVEN CELLS IN A DYNAMIC HTML TABLE” filed, Dec. 7, 1999; Ser. No. 09/455,709, entitled “METHOD FOR PROVIDING A VISUAL REPRESENTATION OF DYNAMIC HTML TABLE ATTRIBUTES” filed, Oct. 7, 1999; and Ser. No. 09/455,713, entitled “METHOD FOR ROTATING A DYNAMIC HTML TABLE” filed, Dec. 7, 1999

    BACKGROUND OF THE INVENTION

    1. Technical Field

    The present invention relates generally to Internet publishing technologies and, in particular, to techniques for dynamically serving web pages that include tables populated with dynamic data

    2. Description of the Related Art

    Page serving technologies are evolving at a rapid pace. Since 1997, a number of major technologies have attempted to supplement, if not replace, dynamically generated HTML, i. e. database or CGI scripts used to generate a web page on the fly. These technologies are Sun Microsystems's Java Server Page [JSP], Microsoft's Active Server Page [ASP], and the Extensible Style Sheet Language [XSL/XSLT] being promoted by the World Wide Web Consortium [W3C]. Such techniques provide for the generation and serving of dynamic web page content by enabling a page creator to write HTML and then to embed pure programming logic inside the page markup. Sun's JSP and Microsoft's ASP are similar in that they both are essentially web templates that enable given code [e. g. , code written in Java] to be embedded in static HTML to be served in response to a client browser request

    Although techniques such as JSP and ASP allow page authors to quickly and easily create web pages with dynamically-generated content, these techniques still have limitations. One limitation, in particular, is the inability to format an HTML table from given input data or that exhibits given customization, e. g. , the capability to display highlighted cells based on given data conditions or the ability to format the table to facilitate rotation about any row or column. As is well-known, an HTML table consists of headers, rows and columns. A column represents a type of data. A header is used to display proper name for each column. A row is a set of data that consists of one datum from each column

    Thus, for example, generating an HTML table from dynamic data in a Java server page is a complicated task. To produce a formatted table, one must first obtain the data from given input object[s]. The way to access the data is different depending on the implementation of those objects. One may implement their input as a JavaBean that uses indexed properties or vanilla properties. Others may implement a series of data beans using a combination of indexed property and property. Additional ways of accessing data might be through an XML document object model [DOM] or a JDBC ResultSet. With all these variations, it is difficult to format an HTML table for a dynamically-generated page wherein input data objects may be retrieved from varying types of input data sources

    Once the dynamic data is obtained, it would also be desirable to format that data within the dynamic HTML table. One such type of formatting is highlighting. As is well-known, it is fairly simple to highlight a given column or row in a dynamically-generated HTML table, and it is also known to highlight a specific cell in a static HTML table. However, there is no known technique for highlighting a given cell in a dynamically-generated table when data in that cell satisfies a given condition. For example, for a bank online statement wherein the information returned to the requesting user is a table, it would be desirable to be able to highlight a given cell to indicate that the user's checking account balance, for example, has fallen below a given amount. Thus, it would be desirable to be able to convert dynamic data [such as the result of a database query] into a formatted tabular representation in which certain table cells are conditionally highlighted based on the characteristics of the dynamic data to be presented in the cell

    Another type of table functionality that is currently unavailable in the art is the ability to produce a single dynamic page that will render a table correctly in any given horizontal or vertical orientation. There are many reasons for rotating a tabular representation in a web page. To give a simple example, some languages, such as Hebrew, are read right-to-left. As another example, assume a table compares the prices of vegetables for five different groceries. Because there are hundreds of vegetable types, the page author will want to be able to rotate the table so that it has. five columns but hundreds of rows. When a table is rotated, however, the corresponding attributes in the table should change as well. If there are many attributes in the HTML table, however, there will be significant changes required when the orientation is altered. With a formatted table, a formatter for a column should become a formatter for a row. Implementing formatters for all of the expected orientations, however, is quite difficult

    For a Java programmer who is not an HTML expert, it is not easy to completely understand the behavior of the attributes in a table that is going to be rotated. In the example described above, this is because there are a large number of attributes associated with the HTML table. In the prior art, there is no means available to show the position and precedence of all of these attributes. Although the documentation generated from Java class files contains the HTML table attributes, such documentation does not show any of the relations among the attributes. Thus, for example, a developer has no simple way to determine the behaviors of given attributes or what rule should govern if a behavior conflict occurs

    The present invention addresses these and other deficiencies of the prior art

    BRIEF SUMMARY OF THE INVENTION

    The present invention describes a table formatter that is useful in formatting a markup language page table having dynamic data. The table formatter provides a number of useful functions including a raw data acquisition object that enables page developers to access different types of data objects for the table using a common interface, a technique to enable a page developer to specify how to convert dynamic data into a formatted representation in which certain table cells are conditionally highlighted, and a technique to enable the page author to format the table so that the contents of the table are independent of the table's orientation. The table formatter is invoked to enable the page developer to set up properties that will be used to create the dynamic table in response to a client browser request for a page that includes the table. Upon receipt of that request at the server, a request object and a data object are passed into the table formatter to generate the table according to the properties and to populate the table from a data source defined by the raw data acquisition object. As noted above, the dynamically-generated table may include conditionally highlighted cells as well as a defined horizontal or vertical orientation. The page that includes this table is then returned to the requesting browser in the usual manner

    Thus, it is a primary object of the present invention to provide a table formatter that is useful at a server for writing a server page [e. g. , using JSP] to produce a dynamic table

    Another more specific object of the invention is to implement a raw data acquisition object to provide an interface that enables third parties to plug-in different types of data objects in the table formatting process irrespective of the type of data or the form in which that data is stored

    According to a preferred embodiment, a method is operative at a server in response to a client browser request for generating a table having dynamic data. The method begins by instantiating a table format object with dynamic data extracted from one of a set of data objects through a common interface. The common interface enables page developers to author customized data getter objects that are used to access data in the set of data objects. The dynamic data extracted from the given data object through the common interface is formatted into the table according to the table format object. The resulting table with dynamic data is then served back to the requesting client browser

    The foregoing has outlined some of the more pertinent objects and features of the present invention. These objects should be construed to be merely illustrative of some of the more prominent features and applications of the invention. Many other beneficial results can be attained by applying the disclosed invention in a different manner or modifying the invention as will be described. Accordingly, other objects and a fuller understanding of the invention may be had by referring to the following

    BRIEF DESCRIPTION OF THE DRAWINGS

    For a more complete understanding of the present invention and the advantages thereof, reference should be made to the following Detailed Description taken in connection with the accompanying drawings in which

    FIG. 1 is a simplified illustration of a client-server environment in which the present invention may be implemented;

    FIG. 2 is a high level flowchart illustrating a known technique for handling a . jsp page request; and

    FIG. 3 is a high level flowchart illustrating a preferred method of the present invention for creating and using a table format object to generate a dynamic HTML table;

    FIG. 4 is a detailed flowchart illustrating the operation of the table format object in response to a page request received at a server;

    FIGS. 5A-5B illustrate representative HTML tables illustrating the table cell highlighting function of the present invention;

    FIGS. 6A-6D illustrative different versions of a table using the same set of data that may be created using the table format object of the invention;

    FIG. 7 illustrates a graphical user interface for a table format object customizer tool of the present invention;

    FIG. 8 illustrates a representative state of the customizer tool;

    FIG. 9 illustrates the actual dynamic table that is generated based on the customizer tool state illustrated in FIG. 8;

    FIG. 10 illustrates a representative table attribute chart; and

    FIG. 11 and FIG. 12 illustrate a corresponding portion of the table format object's documentation for the attribute that is displayed as a result of the user linking on the columnPrefix attribute in the table attribute chart in FIG. 10

    DESCRIPTION OF THE PREFERRED EMBODIMENT

    The present invention is implemented within a page handling framework and runtime engine operative on a server in a computer network such as the Internet. As is well-known, in the Internet paradigm as illustrated in FIG. 1, a client machine, such as machine 100, may use an application, such as a web browser 102, to access a server 104 via a computer network 106. Network 106 typically includes other servers [not shown] for control of domain name resolution, routing and other control functions. A representative server 104 is a computer or workstation having at least one processor 108, system memory [e. g. , RAM] 120, disk or other permanent storage 122, I/O devices 124 a-n, an operating system 126, a server program 128, and an application programming interface [API] 130 that provides extensions to enable application developers to extend and/or customize the core functionality thereof through software programs including plug-ins, CGI programs, Java servlets, and the like. One such software program is a . jsp page handling mechanism 132, which processes an HTTP page request and generates a response by feeding data into an output stream as will be described. In an illustrative embodiment, the page handling mechanism is implemented in Java and is executable in a Java Virtual Machine [JVM] by a processor in a known manner. Alternatively, the program may be written in whole or in part in native code. The page handling functionality, of course, may be part of the integral web server program

    A representative server machine is an IBM Netfinity platform running the Unix operating system and a server program such as IBM WebSphere Version 2. 0. Of course, any other computer hardware or software may be used

    A representative client is a personal computer, notebook computer, Internet appliance or pervasive computing device [e. g. , a PDA or palm computer] that is Pentium-, PowerPC®- or RISC-based. The client includes an operating system such as Microsoft Windows, Microsoft Windows CE or PalmOS. A typical client includes a suite of Internet tools including a Web browser, such as Netscape Navigator or Microsoft Internet Explorer, that has a Java Virtual Machine [JVM] and support for application plug-ins or helper applications. Communications between the client and the server typically conform to the Hypertext Transfer Protocol [Version 1. 0 or higher], and such communications may be made over a secure connection

    FIG. 2 is a flowchart illustrating a known technique for handling a page request in a server operating JSP. JSP technology uses reusable, cross-platform server components [JavaBeans or servlets] written in Java. Java server pages are HTML files written in a combination of industry-standard HTML, JSP HTML tags, and Java as a scripting language. A JSP file has the extension . jsp and calls the reusable components that reside on the server. The routine begins at step 200 upon the receipt of a request for a web page that is received from a requesting client. The requested page is identified by a URL. At step 202, a Java runtime servlet engine responds to the client . jsp request by retrieving a flat file corresponding to the requested page. At step 204, the servlet engine translates the flat file into a Java servlet. The servlet is then compiled at step 206. At step 208, the runtime engine class loads the servlet. At step 210, the servlet is invoked to cause given [e. g. , customized] web content to be returned to the requesting browser. This competes the processing

    FIG. 3 is a flowchart illustrating the basic functionality of the present invention for creating a table format object and using that object to generate an HTML table as a dynamic page is served in response to a client browser. The routine begins at step 300 to create a table format object called JSPTableFormat[“tableFormatter”]. This object is created during the process of authoring the page. In particular, at step 302, the page author sets up properties on the tableFormatter object including a rawDataGetter, table fields [“method/path”], headerNames, formatbeans, and table attributes. Step 302 may occur upon each client request; alternatively, the table format object or portions thereof may be cached for reuse. As will be described in more detail below, the rawDataGetter is an interface that is used to enable data sources from multiple sources to be sourced into the table format object. In particular, the rawDataGetter provides a generic interface by which third parties can use to plug in different ways of getting data out of varying data sources. The tableFields is a vector that is passed in to the methods of the tableFormatter to specify the paths that the rawDataGetter is to use to get the data from the data source. The headerNames identifies the table header names, and the formatbeans are used to set dates, numbers and the like. The table attributes may also be set either conditionally or unconditionally. The setting of conditional table attributes for a given cell enables the table format object to highlight a given cell upon a given occurrence, as will be seen

    Returning back to the figure, the high level routine then continues at step 304. At this step, the table format object is executed in response to a client request to format the HTML table for the dynamic page being generated. In particular, the request object and the data object [the data source] to be formatted are passed in to the tableFormatter, which then formats the table for use in the page. Thus, at runtime, the routine responds to the client request to the . jsp servlet, creates the HTML table and populates the table according to the properties set [at step 302] in the table format object. This functionality, described as tableFormatter. format[request, dataObject], is described in more detail in the flowchart of FIG. 4

    The routine begins at step 400 in response to the client request. At step 402, an instance of the table format object receives the HttpServletRequest object and a dataObject that is to be formatted as input. At step 404, the table format object uses the rawDataGetter [as will be described below] to extract from the dataObject the data [from the specified data source] for each table cell and the headerNames for each of the columns and rows in the table. The routine then continues at step 406 with the table format object formatting the tableCellRawData according to its column formatters, which may include, for example, currency formatter [$, yen, or the like], date formatter, and the like. Step 406 may be effected using one or more formatbeans. The routine then continues at step 408 with the table format object attaching table, row, column and cell attributes to all individual table cell data according to the properties settings, which may include, for example, font, prefix, color, highlights, and the like. Among other things, this step allows conditional highlighting of given cell data on a per attribute basis. At step 410, the table format object attaches the attributes to each HeaderName. The routine then continues at step 412 with the table format object outputting the formatter table according to a tablestyle setting. These settings include, for example, DEFAULTHEADER_TABLESTYLE, LEFTHEADER_TABLESTYLE, RIGHTHEADER_TABLESTYLE, or BOTTOMHEADER_TABLESTYLE. The LEFTHEADER_TABLESTYLE setting rotates the whole table to the left. The RIGHTHEADER_TABLESTYLE rotates the whole table to the left. The BOTTOMHEADER_TABLESTYLE setting rotates the whole table upwards. Using the style settings, the table format object may selectively alter the orientation of the generated table on a dynamic basis. Step 412 completes the processing in response to the client browser request. The result of this process is an HTML table for a dynamically-generated server page

    The following is a more detailed description of several of the features of the inventive table formatter

    JSP [Java Server Page] Raw Data Getter

    As described above, to produce a formatted table, one must first obtain the data from input object[s]. The way to access the data typically is different depending on the implementation of those objects. The rawDataGetter interface of the present invention provides a technique that separates the method of gathering raw data for a dynamic page from the steps necessary to format the data. This interface allows developers to access data in the way they want, and then to apply formatters [e. g. , Java base classes] on the raw data. In particular, the rawDataGetter interfaces multiple data sources to the table format object so that third parties may plug in different ways to get their data out of various types of data object[s]

    In a preferred embodiment, raw data is accessed using the so-called JSPTableRawDataGetter interface, which includes a setter and a getter for tableRawDataGetter on the JSPTableFormatter. A setter enables setting of an object that implements the interface, while a getter enables the retrieving of the last object that was set. A default implementation for the rawDataGetter handles indexed properties or collections. The interface may also include rawDataGetters for accessing data via a property path or through multiple Java objects such as JavaBeans. These rawDataGetters cover a large number of cases. For special cases, developers may customize the rawDataGetter to read their special input objects. As a result, page developers thus implement the input to suit their design and provide the implementation of the JSPTableRawDataGetter to access their input inside a JSPTableFormat Class

    The following is the JSPTableRawDataGetter interface that a third party may implement to obtain raw data from its data sources

    public interface JSPTableRawDataGetter

    extends Serializable

    {

    /**

    *@param object the data object for formatting

    *@param tableFieldTokens a vector of fields in a table

    *@return a two dimensional array of object

    */

    public Object[ ][ ]

    getTableRawData[Object object,

    Vector tableFieldTokens];

    /**

    *@param object the data object for formatting

    *@param tableFieldTokens a vector of fields in a table

    *@param preferHeaders an array of customized header names

    *@return an array of header strings

    */

    public String[ ]

    getTableRawDataHeader[Object object,

    Vector tableFieldTokens,

    String[ ] preferHeaders];

    public boolean

    acceptType[Class aClass];

    }

    The following code represents an illustrative implementation for the interface

    Public class SimpleRawDataGetter implements JSPTableRawDataGetter

    {

    public Object [ ] [ ]

    getTableRawData [Object object,

    Vector tableFieldTokens]

    {

    return [Object [ ] [ ]] object;

    }

    public String [ ]

    getTableRawDataHeader [Object object,

    Vector fieldTokens,

    String [ ] headerNames]

    {

    return headerNames;

    }

    public bookean

    acceptType [Class aClass]

    {

    if [aclass. equals [Object [ ] [ ] . class]] {

    return true;

    }

    return false;

    }

    }

    In this example, the getTableRawData method creates a two-dimensional array of objects for the table and then loops through a vector of data field tokens to obtain the entries. The getTableRawDataHeader method then passes in the data object, the column indicators and the preferred header names [unless the data object dictates otherwise]. It should be noted that the implementation of JSPTableRawDataGetter to allow JSPTableFormat to accept a two dimensional array is not meant to be limiting. This embodiment is shown merely to illustrate how easy it is to extend the JSPTableFormat bean to accept new object types. A page developer may readily supply implementations for other data source inputs including, without limitation, JDBC ResultSets or SQLJ Cursors

    Thus, the raw data acquisition interface affords developers freedom to gather data in the way they want and to populate dynamic HTML tables with that data. Unlike the prior art, developers do not need to change their design to use the table formatter. If, for example, they use standard Java beans as their data beans, the default rawDataGetter can be used. Moreover, the interface provides flexibility to enable the developer to implement a custom way of accessing data. Thus, for example, if one wants to obtain data from a given database, all the developer need do is to write his or her own rawDataGetter Java object. This developer-defined rawDataGetter object, which may be identified as JSPDataBaseRawDataGetter java, then implements the JSPTableRawDataGetter to carry out the three methods in the interface. Those methods then obtain the data for a table and its headers. Thus, to activate the rawDataGetter in the JSPTableFormatter, the developer simply adds the above-illustrated code in his or her . jsp page. When the page request is received, the table formatter formats the data obtained from the JSPDataBaseRawDataGetter defined by the page developer. In this way, the invention provides an interface that can be used by third parties to plug-in ways to get data out of well-known or specialized data objects

    Highlight Certain Cells in Dynamic HTML Table

    The present invention also enables a page author to establish conditions under which a given cell's data may be highlighted in some manner. In a simple example, if the page being returned includes an online bank statement, a table cell identifying the customer's checking account may be selectively highlighted if the data therein indicates that the account has less than a given amount [e. g. , below $500]. The purpose of conditionally highlighting given cell data is to draw the user's attention to the field

    To accomplish this function, the table formatter implements very flexible row, column and cell prefix/suffix property methods. These methods allow page developers to overwrite default values and to specify the row number or column number in the dynamic table to set extra property information for a cell that satisfies a given condition. Preferably, this condition is then checked every time the dynamic page is formatted

    As noted above, the JSPTableFormatter formats dynamic data and produces the HTML table. Developers can extend the get prefix/suffix methods for row, column and cell in the table format object to dynamically control cells that satisfy given conditions. The following is illustrative code [a MyTableFormat object or bean] that may be used for this purpose. This code highlights any cell in any column of the table if the value for that cell is less than zero. Of course, this is merely an illustrative condition

    public class MyTableFormat

    extends JSPTableFormat

    {

    public String

    getCellPrefix[int[ ] order,

    int row,

    int column,

    Object obj]

    {

    if [column ==3]{double amount=[[AccountSummary] obj]. getItemAmount[row];

    if [amount

    Chủ Đề