Overview
The CLAMS CLAIMS Direct Web Services (CDWS) offer a variety of entry points into both the data warehouse and SOLR index. These are mid-to-high-level entry points and can satisfy most requirements pertaining to searching and extracting data for a typical search/view application. There are, however, corner cases which may require more intricate extraction of particular information. On the other hand, there may also be situations where massive amounts of data need to be extracted for further, down-stream processing. The following discussion will touch on solutions for both of these cases.
...
The basic structure of the PostgreSQL database housing the XML content is best described as a collection of tables containing the raw XML of every patent document available in CLAIMS Direct. Each table is a section of the XML document, referred to as a container, and each table is named according to the XML container data it it contains, e.g.,
Table | Container | Description |
---|---|---|
xml.t_publication_reference | publication-reference | Document publication information |
xml.t_invention_title | invention-title | Document title(s) |
xml.t_claims | claims | Document claims |
...
The XML is always in the content
(Postgresql PostgreSQL type: XML) column.
select content from xml.t_publication_reference where publication_id=xml.f_ucid2id( 'US-5551212-A' ); -------- <publication-reference fvid= "71329085" ucid= "US-5551212-A" > <document-id> <country>US</country> <doc-number> 5551212 </doc-number> <kind>A</kind> <date> 19960903 </date> <lang>EN</lang> </document-id> </publication-reference> |
Info |
---|
The invaluable utility function |
Extracting Pieces of the XML Content
As mentioned above, all content
columns are of type XML and therefore the internal PostgreSQL xpath functionality can be used. There are a variety of utility functions provided by CLAIMS Direct that mimic DOM functionality, e.g.
Function | Example | |
---|---|---|
| Extract text of node:
| |
| Extract single attribute value:
| |
| Test presence of a particular node:
| |
| Select a node (type XML) satisfying the given xpath expression:
| |
| Select and an array of nodes satisfying the given xpath expression:
| |
| Select an array of nodes based on element name:
| |
| Select the name of the context content node:
| |
| Select all child nodes:
| |
| Concatenate all child text nodes:
|
...
Although the underlying architecture of the Claims CLAIMS Direct postgreSQL PostgreSQL database is a data warehouse, creating normalized relational views into the XML content is easily achievable using the functions described above. Our example will be to create a relational view of all patent citations. This view will let us SELECT
based on criteria as well as being able to GROUP BY
and ORDER BY
. The first step is to define all the properties of a citation:
...
create or replace function mySchema.f_rdb_citations( integer ) returns table ( publication_id integer, ref_publication_id integer, ref_ucid varchar( 64 ), published date, country varchar( 2 ), kind varchar( 2 ), load_source varchar( 32 ), format varchar( 32 ), source varchar( 32 ) ) as $BODY$ declare v_content xml; v_node xml; v_doc_node xml; begin -- example usage: -- select * from mySchema.f_rdb_citations( xml.f_ucid2id( 'US-9240001-B2' ) ); select x.publication_id, x.content into publication_id, v_content from xml.t_citations as x where x.publication_id=$ 1 ; if not found then return ; end if ; -- loop through all patent citations foreach for each v_node in array ( select xml.f_findNodes( '//patcit' , v_content) ) loop select xml.f_getAttribute( 'ucid' , v_node ) into ref_ucid; select x.publication_id into ref_publication_id from xml.t_patent_document_values as x where ucid=xml.f_getAttribute( 'ucid' , v_node ); select xml.f_getAttribute( 'load-source' , v_node ) into load_source; select xml.f_getAttribute( 'name' , xml.f_findNode( './sources/source' , v_node ) ) into source; -- loop through all forms of the document-id(s) foreach for each v_doc_node in array ( select xml.f_findNodes( './document-id' , v_node) ) loop select xml.f_getAttribute( 'format' , v_doc_node ) into format; select xml.f_textContent( './country' , v_doc_node ) into country; select xml.f_textContent( './kind' , v_doc_node ) into kind; select xml.f_textContent( './date' , v_doc_node ) into published; return next; end loop; end loop; end; $BODY$ LANGUAGE plpgsql VOLATILE COST 100 ROWS 1000 ; |
...
Of course, GROUP BY
and ORDER BY
are available on the returned columns. In addition to SELECT
ing citations for a single document, we can alsoalso JOIN
to table expressions, e.g., assume we are interested in the top 5 cited countries from US grant publication date 2016-05-03:
...