Download CAMV XML Validation Framework

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

Entity–attribute–value model wikipedia , lookup

Microsoft SQL Server wikipedia , lookup

Relational model wikipedia , lookup

Open Database Connectivity wikipedia , lookup

Clusterpoint wikipedia , lookup

Database model wikipedia , lookup

SQL wikipedia , lookup

Oracle Database wikipedia , lookup

PL/SQL wikipedia , lookup

Transcript
XML
<Insert Picture Here>
Validation
Framework
CAMV rules validation engine for XML
David Webber, Information Architect, Oracle Public Sector
Disclaimer Notice
The following is intended to outline Oracle general
product direction. It is intended for information
purposes only, and may not be incorporated into any
contract. It is not a commitment to deliver any
material, code, or functionality, and should not be
relied upon in making purchasing decisions.
The development, release, and timing of any features
or functionality described for Oracle’s products
remains at the sole discretion of Oracle.
Slide 2
Agenda
• Concepts and Technology
• Rules Primer with XPath
• Advanced Rules Techniques
• Code table and SQL lookups
• Apache ANT test suite automation tool
– Test, Evaluation, And Measurement (TEAM)
• Summary and Resources
© 2012 Oracle Corporation – All Rights Reserved
3
Concepts and Overview
Running CAMV interactively
CAMV batch test suites
Use Cases
CONCEPTS AND TECHNOLOGY
Conceptual Overview
XML Validation Framework
Design
Test
Deploy
Application
CAM Editor
DB
CAMV
XML
XML
Data Delivery
SQL /
XML
FMW
RULES
CAMV
Web
•
Visual Editor
•
Generate Data
•
SQL Browser
•
Validate Data
•
CAMV
•
Dictionaries
•
Send Data
•
Web Services
•
Drag and Drop
•
FMW / BPM
•
Device
•
Browser
•
Server
XML Validation Framework Benefits
• CAMV component designed to deliver flexible and
context aware XML validation services
• Accelerates information sharing adoption and
deployment (compatible with the NIEM approach)
• Supports extended communities and XML diversity
• Allows reference / conformance test suite development
• Uses XML configuration templates + code-less methods
• Integrates into Oracle Fusion Middleware foundation
• Uses OASIS Content Assembly Mechanism (CAM) open
public standard for validation templates and rules
© 2012 Oracle Corporation – All Rights Reserved
6
CAM Validation Components
Structure
Rules
Code Lists
SQL Query
Template
(compiled)
Database
Lookup
(optional)
Results XML
XML
instance
CAMV
Java Handler
Errors and
Warnings
CAMV Validation Engine
•
•
•
•
•
•
Standalone XML validator using XPath rules
Context aware and declarative rules approach
External and local parameter definitions
Integrated with CAM editor menus for interactive testing
External code list and SQL table lookup support
Configurable error levels – error, warning
– Java error results object returned
– Embedded validation results attributes in XML results
– Can use XSLT for post-validation result handling
• Callable via Spring framework or Java API
© 2012 Oracle Corporation – All Rights Reserved
8
CAMV – Template Controlled Processing
Information
Exchange
Application
Services
Input
XML
Control template contains
information of the exchange
structure design and rules of data
handling and value ranges
Template
Agile
Structure
Deploy
Rules
Configuration
CAMV
Annotations
Parameters
Valid
XML
Process
Running Validation Rules Tests
• Fault tolerant validation engine allows testing of XML
instances against actual exchange rules.
• Critical to ensure that the exchange validates actual
live production example scenarios correctly
• Allows deployed solution to directly match documented
exchange details (e.g. NIEM IEPD) – no coding delta
• Errors can be reviewed interactively in exchange visual
interface
• Post-processing of validation results allows unit
regression tests to be created with reporting of errors,
warnings and information level notes
© 2012 Oracle Corporation – All Rights Reserved
10
Editor Interactive Rule Validation
Information
Exchange
Application
Template and
XML Sample
CAM Editor
Interactive
Validation
1
Validation Results
3
Content
Rules
2
CAM Editor / CAMV Environment
XML Test
Instance
CAM
Editor
CAM
template
XSLT
CAMV
XML
Validation
Result
CAM
Editor
Reports
Reviewing Validation Results HTML
Results of XSLT error script applied to sample validation output
CAMV Batch Run Example
Quick guide and jump start kit available for ANT processing
Quick Syntax Primer
Controlling Scope, Context, Evaluation
Dynamic Structure Components
CAM Editor Rule Wizards
XPATH RULES TECHNIQUES
XPath Syntax Primer
• XPath is a simple assertion language where
expressions reference components hierarchically
within an XML instance structure – e.g.
– /animals/canines/domestic/dogs/poodle[1]
– /animals/canines/domestic/*
– /animals/canines/domestic/ancestor::breed/@type
• CAMV uses the XPath v2.0 Java library
• In CAM templates XPath is used to express usage
rules and content details of the XML structure and
its components
– (e.g. optional, repeatable, date, number, Boolean, decimal
and so on)
© 2012 Oracle Corporation – All Rights Reserved
16
XPath Functions
XPath Function sampler
logical
concat(string,string,…)
substring(string,start,len)
string-length(string)
normalize-space(string)
upper-case(string)
contains(string1,string2)
Yes
starts-with(string1,string2)
Yes
not(arg) or(arg) and(arg)
Yes
exists(item,item,...)
Yes
count((item,item,...))
/bookstore/book[price>35]/title
CAM XPath Extensions (most used)
Structure Functions
Content Functions
makeOptional(xpath…)
setNumberMask(xpath,arg)
makeRepeatable(xpath…)
setStringMask(xpath,arg)
makeMandatory(xpath…)
restrictValues(xpath,args)
excludeTree(xpath…)
setDateMask(xpath,arg)
makeNillable(xpath…)
datatype(xpath,arg)
setChoice(xpath…)
setLength(xpath,arg)
setLimit(xpath…)
lookup(xpath,args)
setValue(xpath,arg)
printMessage(xpath,arg)
setNumberRange(xpath,args)
setDefault (xpath,arg)
CAM templates and XPath expressions
• Within a CAM template XPath expressions are found in the
<as:BusinessUseContext> section of the template.
© 2012 Oracle Corporation – All Rights Reserved
19
Default Structure Handling
By default all structure components are required and string content
Content Masks
Structure control
Controlling Scope and Context
Condition controls if and when the content rule action applies
Condition can control structure as well; optional, mandatory, exclude
Condition can reference different component(s) for contextual rule actions
Expressing Business Rules Examples
Business Rule: Items with color attributes don't need a tray
number—the color is sufficient for picking the item:
<as:constraint condition="exists(//Item/@color)"
action="makeOptional(//Item/TrayNumber)" />
Business Rule: If order weight exceeds 25 kg, purchase order
must specify a freight carrier:
<as:constraint condition="//Item/@weight > 25"
action="makeMandatory(//Item/FreightHandler)">
Using XPath axis referencing (when things are not adjacent in
hierarchy):
<as:constraint condition="exists(ancestor::Item/@color)"
action="makeOptional(//Item/TrayNumber)" />
* Excerpted from Michael Sorens DEVX CAM article examples -http://www.devx.com/xml/Article/41150
Example Cross Component Rules
Business Rule: Providing warning if PurgeDate is earlier than
PurgeReviewDate
<as:constraint
condition="//sbl:PrivacyDetails/sbl:PrivacyPurgeDate < //sbl:PrivacyDetails/sbl:PrivacyPurgeReviewDate"
action="printMessage(//sbl:PrivacyDetails/sbl:PrivacyPurgeReviewDate,Warning: Review date not before purge
date)">
<as:annotation/>
</as:constraint>
Business Rule: Location must contain an address or a highway
or coordinate set
<as:constraint
condition="not(./nc:LocationAddress) and(not(./nc:LocationHighway))
and(not(./nc:LocationTwoDimensionalGeographicCoordinate))"
action="printMessage(//j:TargetLocation/sbl:Location,Missing Location information)">
<as:annotation>
<as:documentation type="documentation">Example of advanced rule</as:documentation>
</as:annotation>
</as:constraint>
CAM Editor rule XPath entry wizard
1
restrictValues()
XPath reference
2
Allowed values
CAM Editor New Rule XPath entry wizard
XPath rule scope check boxes
Allowed values
entry
Introduction to CAM code lists
Advantages
Tools and Hints
CODE LISTS AND SQL LOOKUP
Code lists
• CAM lookup() function allows referencing to external XML
lists of values
• Can replace use of restrictValues() static lists
• CAM lookup() function can reference SQL table for dynamic
value checking
• Where to get code lists?
1. Import XSD enumeration schema into CAM lookup lists
2. Convert UBL Genericode into CAM lookup lists
3. Dump from database into lookup list XML format
(cool use for SQL to XML feature of CAM database designer)
© 2012 Oracle Corporation – All Rights Reserved
27
CAM Code list XML format
Code list name
Code
value
Textual
value
Code lists examples
• Load lookup list XML into CAM editor
• Assign lookup() rule to XML component
• For SQL lookups – need to define connectivity to database
and the SQL query to perform
– (example SQL lookup available from http://www.cameditor.org)
© 2012 Oracle Corporation – All Rights Reserved
29
Combining Rules and Code lists
• Real power of code lists and CAM – ability to select code list
values based on XPath rule criteria to handle different partner
configurations, versioning and cross-table validations
– e.g. Ford / Mustang | Chevy / Corvette
– Message version id = 1.6 – use code list XYZ-1-6
© 2012 Oracle Corporation – All Rights Reserved
30
Code Lists Summary
• Lookups can be to external XML file instances
• Simple XML format for optimized performance and
readability
• Dynamic runtime control via XPath rules to select lists
to be applied
• Lookup can reference SQL statement for database
content checking
– e.g. part numbers, customer id, order number
© 2012 Oracle Corporation – All Rights Reserved
31
CAMV Java Validation Engine (OneJar)
Java API and Spring API support
Integration with JAX-WS
Templates provide flexible rule validation
Codelists and SQL lookups
ANT batch test suites
CAMV SUMMARY
CAM Project Resource Site
SNAPSHOT OF PROJECT
ACTIVITIES
50,000 CAMeditor.org page
visits in one year
130+ countries have
downloaded tools;
30% of visitors are from U.S.
450+ downloads weekly
20,000 yearly downloads
1,000 Macintosh
1,000 Linux
100 student views of online
video training resources weekly
6 languages now available
www.cameditor.org
‹#›