"DBXML programmer manual

xiaoxiao2021-03-06  52

TM programmer manual

Ver 2.0

Updated: 2003-12-1 3:55 PM translation: ksu99@163.com

Introduction

DBXML is a local source database (NATIVE XML Database, NXD). NXD stores XML with intrinsic format to achieve faster overall processing speed. DBXML is based on J2SE 1.4, and should also be run on J2SE 1.4.

2. The agreement used in this document (Conventions Used In this Document)

Throughout this article, use the formatted convention to convey special things, such as source code examples, terminal sessions, and prompts. These formatted agreed are as follows:

2.1. Terminal Session

Terminal session uses equality demonstrations on black background. Such as:

Collection: / MyCollection / MyCollection>

2.2. Terminal Instructions

Terminal instructions are typically included in the terminal session to guide the developer's input with yellow bold words. Such as:

Collection: / mycollection / mycollection> ls test * .xml

TEST1.XMLTEST2.XMLTEST39.XML

2.3. Document Note

Document comments are not essential for documents, but other information can be provided. Such as:

REMINDER: DON 'To Wash Your Hands After You Delete Your XML Documents

2.4. Example Source Code (Example Source Code)

The instance source code is displayed with a relatively wide font on a light gray background. Such as:

Public static void main (string [] args) {system.out.println ("Hello World!");

3. Quick Installation Guide

3.1. NuiX Usage Description (omitted)

3.2. Windows Usage Description (Windows Instructions)

Windows installation file name is dbxml-2.0-beta.zip

1) Unfold the file to the selected directory. The expanded file is generated in a subdirectory named DBXML-2.0.

2) Set the environment variable DBXML_HOME as the above subdirectory, such as "C: /DBXML-2.0".

C: /> set dbxml_home = c: /dbxml-2.0

3) Add Settings "% dbxml_home% / bin" to the environment variable PATH.

C: /> set path = "% dbxml_home% / bin;% PATH%"

4) Start the server, call the script file Startup.bat

C: /> CD% DBXML_HOME%

C: /dbxml-2.0> startup

5) Thorough inspection of the DBXML command line tool with the server connection:

C: /dbxml-2.0> dbxml

> Connect User = Scott Pass = Tiger

Connected /> col / system / sysconfigcollection: / system / sysconfig / system / sysconfig> show database.xml

... a Document Should Be Displayed ... / System / Sysconfig> Shutdown

/ system / sysconfig> EXIT

note! The default, DBXML has two users and two roles. A user name is 'Scott', the authorization role is 'admin'. Another use of 'guest', authorization role is 'guest'. This 'Guest' user can read DBXML Stylesheet Collection by default. System administrators may wish to delete this user and its role.

4. Core Concepts

This section discusses some core concepts in dbxml. This includes how DBXML manages document collection, how to be indexed, how to execute, and how to enhance the server using expansion and triggers.

4.1. Collection model (The Collection Model)

DBXML manages documents in a collection. Many collections can be created and managed simultaneously. The collection can also be swoked in a hierarchical manner, very like the directory structure of the operating system. A single collection can be associated with multiple indexes, expansion, triggers, and subgroups. Similarly, a set can store an XML document or binary stream.

The storage engine of the collection underlay is called the file manager. By default, DBXML uses a local file manager called BTreeFiler, but other file managers will be used for special purposes. These files include Memfiler, FSFiler, and DBFiler.

BTreeFiler is a default local file that handles DBXML. It supports transactions and logs.

Memfiler is used to temporarily store, and the file content is destroyed when the server is restarted.

FSFiler is used to manage content located in the operating system directory.

DBFILER is used to complete the relationship between or from the relational database table.

Regardless of the file manager used, DBXML uses the same program interface to reveal the content, so the bottom Filer is transparent to the developer.

Although documents in a collection do not need to be constrained in a common mode, it is a good habit of using a single collection that contains similar documents, which is easy to perform retrieval and queries for collection.

Note: Currently, the DBXML set is independent of the mode, which is compensated to develop a model-based authentication for documents stored in a collection. The future DBXML versions will include internal XML mode support.

4.2. Document and Records (Documents and Records)

DBXML can store an XML document or binary stream (record), but cannot be performed at the same time. The XML document can be stored as binary stream, but will not benefit from marking, compression, and retrieval. DBXML is not a multimedia database, so it is not recommended to store large amounts of binary flow, understanding it is important. Limiting that binary flow is not more than 500K bytes is a good idea.

4.3. Indexes

A collection allows multiple indexes to be associated with them. Index is a file structure that allows for optimal retrierators based on structures or values ​​of these documents to a collection of documents. DBXML currently provides three indexes. They are ValueIndexer, NameIndexer, and FullTextIndexer. Indexes are created based on element and / or attribute mode.

4.4. Query Resolvers

If you don't have a way to query these documents or part of them, these document collections and indexes of the value in the document are not too many. DBXML provides you with several query parsing systems to achieve this. The query parser is registered with the entire database. The query is performed for a specific collection or a set of documents in a collection and references in a style name. DBXML supports the following style: XPath is a simple path syntax, which is similar to the directory path in UNIX or DOS. It allows returning to the resulting and assignment determination filtering.

XSLT is a transformation language that converts XML into other formats. These formats include XML, text, hypertext, or even PDF formats when using XSL formatted, or even PDF formats. The DBXML XSLT query can be performed on a single document or execute over the entire set or an XPath query result.

Xupdate is also a similar transformation similar to XSLT, but its syntax is relatively simple, and its purpose is to modify the documentation in proper position.

FullText is a search engine style query with the ability to search for multiple words with, or assign values. The full text query can also be filtered using XPath expression.

4.5. Extensions

Expansion is used to add additional capabilities to the DBXML server. The expansion is a Java class that implements the expansion interface, which is exposed in the way of Web Service endpoints. Triggers and other expansions can also be referenced. What is important is to remember that only a common method of obtaining a special child node of a class parameter, you can expose the web service endpoint.

4.6. Trigger (TRIGGERS)

The trigger is a Java class that implements the trigger interface. This interface specifies several methods to implement the returned processing from a collection. Set the trigger before and after the following events:

Document Insert - is activated when INSERTDocument, INSERTRECORD, SETDocument, or setRecord method is called

Document update - activated when setDocument or setRecord method is called

Document deletion - activated when the Remove method is called

Document Retrieval - activated when getDocument or getRecord method is called

The trigger event excited before insertion, update, and delete is disabled by the trigger. The trigger also gives the programmer opportunity to perform this type of task such as a document before confirming and document reaching the database.

4.7. Transactions

Currently, DBXML provides transaction log processing capabilities at the Direct API level. At the level here, all database operations must be performed using a transaction reference, and only submit is allowed. These capabilities have not provided DBXML client / server API, this is a good thing, it is not good.

For the client / server task, the transaction is a detail that applies developers can easily ignore. DBXML Customer Service / Server API automatically illustrates and calls submitted transactions for each database.

Note: Future DBXML versions will include all-round transactions in the customer server layer, but now, log transactions can only be controlled by Direct API.

5. Command line tool (Command Line Tools)

The dbxml command line is a similar command interpreter interface, human-machine dialog and script provide database, collection, and document management functions. To launch the DBXML command line tool, make sure your DBXML_HOME environment variable has been properly set (refer to Quick Install Guide) and your PATH environment variable value includes the 'bin' path under the DBXML_HOME directory. The DBXML command line includes a help system to help you use these commands.

5.1. Connection with database

Using the command line tool is quite easy to connect with the DBXML database, you just use the connect command. The connection command is controlled both the DBXML drive type used, but also controls the host and authentication parameters that use this drive type to connect to a server. By default, the connect command uses the XML-RPC driver to connect to the local computer connection with the DBXML standard port without using the authentication parameters. This will be perfect, except for facts, DBXML's standard security model requires username and password to verify the identity of the database, so you need to provide a username and password. For example:> Connect User = Scott Pass = Tiger

Connected

This will try to log in and connected to the local database with the username 'Scott' and password 'tiger'. In dbxml, 'scott' is a self-bootrigate user, and its role is a newly created database.

Did You Know? For database history buffs (all three of you), the username 'scott' and password 'tiger' were once used to login to Oracle's demo schema, and refer to one of Oracle's founders (Bruce Scott) and his cat ( Tiger.

You can connect an alternate computer with methods that add hosts and (free) port parameters.

> Connect User = Scott Pass = Tiger Host = MyHost.mydomain.com Port = 7280

Connected

DBXML connection command

command

Description

usage

Connect

Connect with a DBXML database server

Connect [Connection Properties]

Disconnect

Disconnect the connection with the DBXML server

Disconnect

5.2. Collection Management

Manage and manipulate a collection of DBXML databases, directly related to the next step, and in many ways to the UNIX directory management and manipulation.

Creating a collection is similar to the following example:

/> mkcol mycollection

Collection 'Mycollection' Created

This will create a collection in the database root directory, named the 'MyCollection' default set type store compressed XML document. If you are intended to create a collection that can store the binary stream, you can add Type parameters in the command.

/> MKCOL MyCollection Type = binary

Collection 'Mycollection' Created

DBXML collection management command

command

Description

usage

Lscol

Sub collection list for a collection

Lscol [wildcard]

COL

Set the default collection

COL 'Collection'

Mkcol

Create a new document collection

Mkcol 'Collection Name' [Properties]

Rmcol

Remove specific subsets from a collection

Rmcol 'Collection Name'

5.3. Management Security

Safety management program

DBXML currently supports three security management programs.

NosecurityManager does not provide security to access the database does not require authentication.

SimpleSecurityManager provides easy security for a single user name and password throughout the database. The username and password are defined in the System.xml configuration file of the database.

DefaultSecurityManager is conveniently named because of its default security management program. It provides access control based on users and roles stored in the database system collection. Command set

There are three groups of security-related orders, they must be familiar.

Users - User-related commands allow you to manage database users. This includes creation, deleting, role participation, and password settings. When creating the first time, the user has no password settings. In DBXML, he cannot enter the system unless a user's password has been set. The user sample will be the default dbxml user 'scott' '.

Roles - Role assigns a list of access controls. They are abstractions that allow databases to avoid feature-level granular access control portals, which are different from individual users. Role related commands include creation, deletion, and user participation. The role is the default dbxml role 'admin'.

Access Control Lists - ACLS is an authorization to access the database. Access is authorized to the collection level, neither recursive nor automatic. Simply create a collection does not authorize to create a user to access this collection. Similarly, accessing the parent collection does not imply the automatic subset.

Note: The command line tool is built around the default security management program. If you don't use the default security manager, use these commands to modify users, roles, and access control data will succeed, but there will be no effect, because two security management programs cannot use this data in any way.

example

When you create a collection in DBXML, the collection will initially be unacceptable to the outside world. The database does not automatically add a series of default permissions to creating users, the role of administrators. The following example demonstrates this process:

/> mkcol mycollection

Collection 'MyCollection' Created /> COL MyCollection

Collection: / MyCollection / MyCollection> Grant Admin Read Write Execute Create

Grant Successful (Read, Write, Execute, Create)

DBXML security command

command

Description

usage

LSUSER

List the available database users

Lsuser [wildcard]

AddUser

Add new users to the database

AddUser 'user ID'

User

Modify user properties

User 'user id' 'action' [parameter]

Rmuser

Delete users from database

Rmuser 'user id'

Lsrole

List the available database roles

Lsrole [wildcard]

AddRole

Add new roles for databases

AddRole 'Role ID'

Role

Modify role properties

Role 'Role ID' 'Action' [Parameter]

Rmrole

Delete roles from database

RMROLE 'ROLE ID'

ACCESS

Display collection access control list

Access [role id]

Grant

Give the role

Grant 'Role ID' 'PERMISSE'

Revoke

Undo role authorization

Revoke 'Role ID' 'Permissions'

5.4. Index Management

Effective index management is the key to performance when developing applications using DBXML. A good placement index means that the query interpreter must check 3 documents instead of 300,000 such differences. The type of index used is also important.

Index type

DBXML currently has three types of Indexers.

ValueIndexer (Type =

)

- ValueIndexer is the most universal indexer. It is also the default value without Indexer is being established. Its purpose provides indexing of elements or attributes in documents. For the appropriate index relationship, ValueIndexer may force these values ​​into special types. For example, a value is forced to convert to an integer because of the purpose of sorting. If a value cannot be enforced, it will not be indexed. The type of support is: String - String is the default type of ValueIndexer. The value using the string type index is stored and queried in one word. This means that all front, middle and back spaces are related to the precise query string index. (Translator Note: Space will affect the index)

The TrimMed-Crop type is similar to the string type, except that the index value is normal. The head is removed, and all the middle blank is converted into a space. This means that the space difference does not affect the results of the query.

SHORT, INT, Long - Interest internally expressed as a 64-bit single length integer.

FLOAT, DOUBLE - The floating point type used is internally expressed as a 128-bit compound (64-bit integer, 64-bit decimal).

BYTE - an 8-bit byte type.

CHAR - a 16-bit character type.

Boolean - a bit of Boolean (TRUE, or FALSE, YES or NO, ON), or OFF, 1 or 0).

NameIndexer - NameIndexer Index document element or attribute name entity. This is especially useful for the collection of different mode documents, in which case one element may exist in some documents, not all.

FullTextIndexer (Type = FULLTEXT) - FullTextIndexer Gets the value of the element and attribute, and dismantles them into a single word. Change the grid of these words and extract its trunk for indexing. Extracting the trunk is to take out the words like 'happensening' and 'happen', transform into the same stem. FullTextIndexer is especially useful for content-based search, which is similar to the functions provided by Google's search engines.

Index mode

Index mode is a simple expression that identifies the elements or properties that will be calculated by special indexes. 6 possible mode combination

ELEMENT NAME (Pattern = foo) - indexes all element values ​​(but not their properties).

Wildcard element (Pattern = *) - The value of the index (but not their attribute).

Element Name with attribute name (pattern = foo @ bar) - Index belongs to all 'Bar' attributes of elements named 'foo'.

ELEMENT NAME with WILDCARD Attribute (Pattern = foo @ *) - Indexes all attribute values ​​for elements named 'foo'.

Wildcard Element with attribute name (pattern = * @ bar) - Index belongs to all values ​​named 'bar' in any element.

Wildcard element with wildcard attribute (pattern = * @ *) - Index belongs to all attribute values ​​for any element.

Index mode also supports namespace restriction capabilities. This is achieved by pending elements or attribute names and its corresponding namespace URI, enclosed with square brackets (eg [http://www.w3.org/1999/xhtml]title). This type of mode cannot include namespace prefix because they are not important in name spatial analysis. Moreover, it is important to do not include spaces in these modes.

Note: It is easy to make the index mode to XPath expressions. Although syntax is intentionally similar to XPath expressions, index mode cannot be controlled by XPath. This means that '/ foo [status =' active '] / bar @ id' does not run. In this case, try 'bar @ id'. example

The following example creates five indexes about a collection:

/ mycollection> mkidx myelem_id_value pattern = myelem @ id type = int

Index 'myelem_id_value' created / mycollection> mkidx myelem_name pattern = myelem type = NAME

Index 'MyElem_name' created / mycollection> mkidx myelem_text pattern = myelem type = FullText

Index 'MyElem_text' Created / MyCollection> Mkidx Anyelem_Status_Value Pattern = * @ status type = trimmed

Index 'Anyelem_Status_Value' Created / MyCollection> MKIDX NSELEM_VALUE PATTERN = [http://www.dbxml.com/uri] ELEM

INDEX 'NSELEM_VALUE' CREATED

The first index, 'myelem_id_value' creates a forced integer index for the 'ID' attribute called 'MyElem' in the collection.

The second index, 'myelem_name', establishes a name index for all documents named 'MyElem' elements.

The third index, 'myelem_text', creates a full-text index of all the collections for all elements named 'MyElem'.

The fourth index 'anylem_status_value' creates a crop string index for all the 'status' attributes of any element in the collection.

The fifth index 'nSelem_Value' creates a default (string) value index for all 'ELEM' elements belonging to 'http://www.dbxml.com/uri' namespace.

DBXML index command

command

Description

usage

LSIDX

List a collection of Indexer

LSIDX [Wildcard]

MKIDX

Create a new set index

Mkidx 'Index Name' [Properties]

RMIDX

Remove the specified Indexer from the collection

RMIDX 'Indexer Name'

5.5. Access Document (Storing and Retrieving Documents)

Management and index collection is an excellent thing, but if there is no thing that can be indexed in the collection, it is no longer good for you. Fortunately, the DBXML command line tool also allows you to enter and output content from a collection.

There are two modes in the import and export command. You can enter / output a single file or use wildcard input / output multiple files. If you are processed a single file, the command allows you to use the AS clause to change the name of the file between the file system and the database. This option is not available if multiple files are processed. The import command also allows you to recurse a directory tree to store all the matched files in the current collection.

The following example demonstrates input a single file and rename it:

/ mycollection> import myfile.xml as myDocument.xml

The next example demonstrates input a whole directory to the current collection: / mycollection> import * .xml recursive

DBXML content command (DBXML Content Commands)

command

Description

usage

LS

List keywords in the collection

LS [wildcard]

Show

Retrieve a document from a collection

Show 'Document Name'

Import

Enter content in the collection

Import 'filespec' [as 'name'] [Recursive]

Export

Output content from a collection

Export 'filespec' [as 'name']

RM

Remove specific content from a collection

RM 'FileSpec'

5.6. Trigger and Extensions

Triggers and extensions are basically the same in DBXML, so discuss them is relatively easy to discuss in a merged chapter. Understanding triggers and extensions is that their classes must be available to the server, and package them into jar through Java ClassPath or start them in the DBXML_HOME / LIB directory before the DBXML server starts.

This is an example of adding trigger tools to a collection:

/ mycollection> mktrg name = myTrigger class = examples.exampletrigger

Trigger 'MyTrigger' Created

DBXML trigger and extension (TRIGGER AND EXTENSITION)

command

Description

usage

Lstrg

List a collection of triggers

Lstrg [wildcard]

Mktrg

Register a collection trigger

Mktrg 'Trigger Name' [Properties]

RMTRG

Remove specific triggers from a collection

Rmtrg 'Trigger Name'

Lsext

List an extension of a collection

Lsext [wildcard]

Mkext

Register an extension of a collection

Mkext 'extension name' [Properties]

RMext

Remove specific extensions from a collection

RMext 'extension name'

5.7 Other Options (Other Options)

There are three other orders difficult to classify, so they are conveniently placed in the 'other' option category. These commands include setting command line options, shutting down the server, exiting the command line.

The set command is interesting because it allows you to switch and change different command line options. These options include:

Interactive - The default is set to 'True', which switch command line interaction mode. If it is false, the command line will not reality any human-machine dialog prompt.

Totals - Switching command lines Displays the total list.

Durations - Switching command lines Display execution time

Verbose - Switching command line Whether to display a detailed stack record when an error occurs

CONFIRM - Switching command line Whether to confirm inquiry when deleting an important object such as a collection

The following example Demonstration command line option settings:

/ MyCollection> Set Durations True

Durations True (Execution: 5ms)

Other dbxml commands (Other dbxml commands)

command

Description

usage

Set

Set or display interactive mode features

Set ['Prop Name' [Value]]]]]

Version

Display service system version

Version

Shutdown

Shut down the server

Shutdown [exit code] EXIT

Exit interactive mode

EXIT [EXIT CODE]

6. API Overview (API Overview)

DBXML provides several application interface (Application Programmer Interfaces, APIs), each with its own strengths and weaknesses. An application developer chooses which API usually depends on the needs of their special projects. This section will briefly discuss each API and its benefits.

The full setting information of the DBXML API can be found in the DBXML_HOME / DOCS / API directory.

Note: Through these parts, classes, and interface definitions will be presented. These definitions will be almost always unfinished, usually ignore Javadoc, non-public methods, and fields, non-necessary methods and fields, and launching subseections. Their intention is to be a quick reference rather than a complete definition.

6.1. Direct API (The Direct API)

A direct API is an interface defined by the inner class hierarchy of DBXML. Developers can access internal processing of DBXML engines recently. The classes and methods exposed to this API are very low levels, and it will be critical.

One way to direct API is that this API uses internalized DBXML DocumentTable representation to expose the XML document. DocumentTables is perfect for storage and indexes, but it is difficult to operate for application developers. To mitigate potential setbacks, the direct API also provides an Adapter System that allows developers to surround the DocumentTable APIS. DBXML provides adapters for Dom Documents, Sax Handlers, and Jaxb bundles.

6.2. DBXML Customer API (Client API)

The DBXML Customer API has access to DBXML's universal interfaces for embedding and client / servers. The exposed interfaces and methods are similar to the direct API, but the buffer service is provided for the internal processing of some databases. A good example of this buffering is that the DBXML customer API indicates a special method for processing text or document DOM, while direct API only exposes inner DBXML DocumentTable.

6.3. XML: DB API

XML: DB API is an abstract interface provided in order to access an XML database in a general manner. Several XML databases implements this API, so it provides the greatest potential for developing portable applications.

6.4. Web Services Access

In the overlay, DBXML is a web server and provides a complete HTTP access to the following features. Most of the server can be accessed using XML-RPC protocol. Some features can also be accessed directly using the REST protocol (URL encoding).

转载请注明原文地址:https://www.9cbs.com/read-116576.html

New Post(0)