Syntax Reuse: XSLT as a Metalanguage for  Knowledge Representation Languages                   Tara Athan     Athan Servic...
Situation: Information Overload●   Information           ●   Information Diversity    Abundance                 ●   Charac...
Response: Representation Format           Overload●   Geographical Data                  ●   Knowledge    Formats         ...
Semantic Interoperability:        Translation or Coexistence (I)●   Between disparate KR languages    ●   Translation: RDF...
Semantic Interoperability:        Translation or Coexistence (II)●   Between data and KR    ●   Translation:         –   G...
Metalanguage Strategy:              Semantic or Syntactic●   Semantic                           ●   Syntactic    ●   RDF G...
XSLT: W3C Recommendation●   Turing-complete language    ●   Takes well-formed XML input    ●   Produces arbitrary characte...
Metalanguage MXSL Goals●   Enable reasoning over large, structured legacy    datasets (e.g. in XML or flat files) without ...
MXSL Approach●   Use XSLT to represent the transformation of a set    of parameter bindings into the corresponding    inst...
Example: Captured String SyntaxInspired from IKL: (= (a) a)<ruleml:Equal>  <ruleml:Expr>    <ruleml:Fun iri="#constant"/> ...
XSLT Element Construction<ruleml:Equal> <ruleml:Expr>  <ruleml:Fun iri="#constant"/>  <ruleml:Data xsi:type="xs:string"   ...
XSLT for-each:           MXSL Quantification<xsl:for-each select="$input/v:first/m:binding">  <xsl:variable name="stringPa...
Two-Phase Interpretation1. the application of a metainterpretation totransform the metalanguage instance to anotherinstanc...
Truth-Valuation (I)●   Assume an interpretation I, with vocabulary V and    metalanguage formula F.●   Each metainterpreta...
Truth-Valuation (II)●   Call the remaining set of RuleML formulas S●   The metalanguage formula F is “valid in an    inter...
Metalanguage Requirements (I)●   add element node to output tree, given local    name and namespace as parameters;●   add ...
Metalanguage Requirements (II)●   express the hierarchical and sequential structure    of the output tree isomorphically a...
MXSL Syntax (I)●   <xsl:for-each>, for iteration●   <xsl:element>, for construction of XML elements●   <xsl:attribute>, fo...
MXSL Syntax (II)●   <xsl:stylesheet> (once as the root element)●   <xsl:variable> (once as a header to define the    param...
MXSL Syntax (III)●   <ruleml:RuleML> (once as the last child of    <xsl:template> to define the root for the output    doc...
Example: Structured Data        Axiom Before Generalization<r:Rulebase>                                <r:Atom xml:base="&...
Example: Structured Data (cont.)         MXSL Axiom Schema<r:Rulebase>                                             <r:Atom...
Overview of Infinitary Logic (I)●   Given a base (finitary) language L●    Parameter κ : cardinality of sequences of    co...
Overview of Infinitary Logic (II)●    L(ω, ω) = L●   L(ω1, ω) = countable sequences of “junctions”    ●   If L is FOL, L(ω...
RuleML with MXSL Axiom                  Schemas●    Assert/Rulebase/xsl:for-each –> L(ω, ω) –>    complete, compact●   Ass...
Infinitary Case: In practice●   Nonliteral vocabulary is typically finite●   Literals can be introduced only as needed●   ...
Extensions: xsl:for-each/Query<xsl:for-each ...> <Query>  <Atom><Rel>P</Rel>    <Ind>       <xsl:attribute name="type">   ...
Metalanguage Abstract Syntax●   Grouping symbols entered as pairs through one    command●   Mirrors the structure of the o...
MXSL: For CLIF<xsl:for-each select="$input/v:first/m:binding">  <xsl:variable name="stringParam" select="v:stringParam"   ...
MCLIF(mcltext captured-string-axiom  (for-each    (($stringParam xs:string))    ( =      (apply (squote $stringParam))    ...
Conclusions●   MXSL: a (small) subset of the XSLT language,    which can be used as a syntactic metalanguage    for XML-ba...
Upcoming SlideShare
Loading in …5
×

Syntax Reuse: XSLT as a Metalanguage for Knowledge Representation Languages

657 views
589 views

Published on

=We present here MXSL, a subset of XSLT re-interpreted as a syntactic metalanguage for RuleML with operational semantics based on XSLT proc-essing. This metalanguage increases the expressivity of RuleML knowledge bases and queries, with syntactic access to the complete XML tree through the XPath Data Model. The metalanguage is developed in an abstract manner, as a paradigm applicable to other KR languages, in XML or in other formats.

0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
657
On SlideShare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
6
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Syntax Reuse: XSLT as a Metalanguage for Knowledge Representation Languages

  1. 1. Syntax Reuse: XSLT as a Metalanguage for Knowledge Representation Languages Tara Athan Athan Services, West Lafayette, IN, USA taraathan AT gmail.com presented at RuleML 2012 August 29, 2012 Montpellier, France
  2. 2. Situation: Information Overload● Information ● Information Diversity Abundance ● Characteristics ● Datasets, Texts – Numerical ● Metadata – Textual ● Knowledge Bases – Hierarchical ● Uses – Quantitative Processing – Search – Reasoning
  3. 3. Response: Representation Format Overload● Geographical Data ● Knowledge Formats Representation – Flat: Shapefiles, Tabular Formats Data – RDF (XML, N3, Turtle) – Structured Exchange – OWL (RDF/XML, Formats OWL/XML, Manchester) XML: GPX, ArcGIS XML, RuleML (XML, POSL) ● – KML, GeoRSS, GML2, GML3 – Common Logic (CLIF, ● SQL: GDF CGIF) ● JSON: GeoJSON – F-Logic – Geodatabases
  4. 4. Semantic Interoperability: Translation or Coexistence (I)● Between disparate KR languages ● Translation: RDF to OWL, KIF to CLIF, ... – Issues: Incompatibility, redundancy, inefficiency, lossy ● Coexistence – OntoIOps DOL aims to allow heterogeneous knowledge bases to interoperate without translation● Between disparate data formats ● Translation for computation, optimized in domain- specific applications such as GIS ● Coexistence for visualization (mashups, mapping)
  5. 5. Semantic Interoperability: Translation or Coexistence (II)● Between data and KR ● Translation: – GML3 transforms shapefiles, databases, ... ● Has conceptual models, not model-theoretic, not grounded in ontology ● Not in general invertible ● Coexistence – RDF, RuleML, CLIF allow embedded structured data ● XMLLiteral, <Data xsi:type="xs:any">, ... ● IRI with XPath or XPointer provides fine access, but cant quantify● Need: Metalanguage for Quantification within Embedded Data
  6. 6. Metalanguage Strategy: Semantic or Syntactic● Semantic ● Syntactic ● RDF Graph ● XPath Data Model (XDM) – Is a set of RDF triples – Is also a graph – Model-theoretic – Each node of the graph semantics has an information set – (Limited) inferences may (infoset) be drawn – No interpretations ● RuleML OrdLab Tree – No inferences – Herbrand Semantics ● XSLT uses XDM
  7. 7. XSLT: W3C Recommendation● Turing-complete language ● Takes well-formed XML input ● Produces arbitrary character string output● Expressed in XML ● May be validated by – Relax NG (https://github.com/ndw/xslt-relax-ng) – XSD (http://www.w3.org/2007/schema-for-xslt20.xsd)● Processed by ● Libxslt, Apache Xalan, Saxon XSLT, ...
  8. 8. Metalanguage MXSL Goals● Enable reasoning over large, structured legacy datasets (e.g. in XML or flat files) without large- scale conversion of compact representations into the more verbose RuleML format;● Allow user-specified deductive systems for reasoning over RuleML knowledge bases via axiom schemas;● Enhance the RuleML query capability.
  9. 9. MXSL Approach● Use XSLT to represent the transformation of a set of parameter bindings into the corresponding instances of that axiom schema● Interpret the case when a set of bindings is not specified as an axiom schema ● Syntactically indicated by processing instruction <?xml-stylesheet type="text/xsl" href="kb2.mxsl"?> --> <?mxsl type="text/xsl"?>
  10. 10. Example: Captured String SyntaxInspired from IKL: (= (a) a)<ruleml:Equal> <ruleml:Expr> <ruleml:Fun iri="#constant"/> <ruleml:Data xsi:type="xs:string" >stringParam</ruleml:Data> </ruleml:Expr> <ruleml:Ind>stringParam</ruleml:Ind></ruleml:Equal>
  11. 11. XSLT Element Construction<ruleml:Equal> <ruleml:Expr> <ruleml:Fun iri="#constant"/> <ruleml:Data xsi:type="xs:string" >stringParam</ruleml:Data> </ruleml:Expr> <xsl:element name="Ind" namespace="http://ruleml.org/spec"> <xsl:copy-of select="stringParam"/> </xsl:element></ruleml:Equal>
  12. 12. XSLT for-each: MXSL Quantification<xsl:for-each select="$input/v:first/m:binding"> <xsl:variable name="stringParam" select="v:stringParam" xsi:type="xs:string"/>... <xsl:element name="Ind" namespace="http://ruleml.org/spec"> <xsl:copy-of select="$stringParam/node()"/> </xsl:element>...
  13. 13. Two-Phase Interpretation1. the application of a metainterpretation totransform the metalanguage instance to anotherinstance that is purely in the base language;2. the application of the base language’s model-theoretic interpretation to transform the derivedinstance to truth values.
  14. 14. Truth-Valuation (I)● Assume an interpretation I, with vocabulary V and metalanguage formula F.● Each metainterpretation transformation ● uses one binding of the metalanguage parameters to literals, constrained only by datatype ● produces a “preformula”● Preformulas are “discarded” that either ● Are not syntactically valid RuleML ● Contain names that are not in vocabulary V
  15. 15. Truth-Valuation (II)● Call the remaining set of RuleML formulas S● The metalanguage formula F is “valid in an interpretation I” if all RuleML formulas in S are valid in the interpretation I.● In (exactly) that case, I is a “model of F”.
  16. 16. Metalanguage Requirements (I)● add element node to output tree, given local name and namespace as parameters;● add attribute node to element node, given local name, name-space and value as parameters;● add text node as child of element;● iteratively add, in specified order, a number of nodes to output tree, based on set of parameter bindings represented in structured XML;
  17. 17. Metalanguage Requirements (II)● express the hierarchical and sequential structure of the output tree isomorphically according to the corresponding structure of the metalanguage instance.● In addition, we have the following operational requirements: Instances in metalanguage must: ● validate against the XSLT schema, ● be self-contained, ● be self-executing.
  18. 18. MXSL Syntax (I)● <xsl:for-each>, for iteration● <xsl:element>, for construction of XML elements● <xsl:attribute>, for addition of attributes to XML elements● <xsl:copy-of> with @select, for generation of the values of attributes and contents of element
  19. 19. MXSL Syntax (II)● <xsl:stylesheet> (once as the root element)● <xsl:variable> (once as a header to define the parameter bindings and also as the first children of <xsl:for-each>, once for each parameter in the iteration)● <xsl:template match="/"> (once for the MXSL body)● <xsl:processing-instruction> (zero to many times as the first children of <xsl:template> )
  20. 20. MXSL Syntax (III)● <ruleml:RuleML> (once as the last child of <xsl:template> to define the root for the output document)● <xsl:comment> (arbitrarily within the <ruleml:RuleML> element)
  21. 21. Example: Structured Data Axiom Before Generalization<r:Rulebase> <r:Atom xml:base="&exb"> <r:Equivalent> <r:oid> <r:Atom> <r:Ind iri="#b14507?oid"/> <r:Rel iri= </r:oid> "&exv;#data-record-business?rel"/> <r:Rel <r:Data> iri="&exv;#atom-record-business?rel"/> <ex:record id="14507" <r:slot> xml:base= <r:Ind iri="#name?key"/> "&exb;"> <r:Data xsi:type="xs:string">Tara <ex:name>Tara Athan</ex:name> Athan</r:Data> <ex:name>Athan </r:slot> Services</ex:name> <r:slot> </ex:record> <r:Ind iri="#business-name?key"/> </r:Data> <r:Data xsi:type="xs:string">Athan </r:Atom> Services</r:Data> </r:slot> </r:Atom></r:Equivalent></r:Rulebase>
  22. 22. Example: Structured Data (cont.) MXSL Axiom Schema<r:Rulebase> <r:Atom> <for-each select="$input/ex:business/m:binding"> <attribute name="base" namespace="&xml;"> <variable name="oid" select="ex:oid" <copy-of select="$base/node()"/> xsi:type="xs:string"/> </attribute> <variable name="base" select="ex:base" <r:oid> xsi:type="xs:anyURI"/> <r:Ind> <variable name="name" select="ex:name" <attribute name="iri" namespace=""> xsi:type="xs:string"/> <copy-of select="#b"/> <variable name="bname" select="ex:bname" <copy-of select="$oid/node()"/> xsi:type="xs:string"/> <copy-of select="?oid"/> <r:Equivalent> </attribute> <r:Atom> </r:Ind> <r:Rel iri="&exv;#data-record-business?rel"/> </r:oid> <r:Data> <r:Rel iri="&exv;#atom-record-business?rel"/> <ex:record> <r:slot> <attribute name="id" namespace=""> <r:Ind iri="#name?key"/> <copy-of select="$oid/node()"/> <r:Data xsi:type="xs:string"> </attribute> <copy-of select="$name/node()"/> <attribute name="base" namespace="&xml;"> </r:Data> <copy-of select="$base/node()"/> </r:slot> </attribute> <r:slot> <element name="name" <r:Ind iri="#business-name?key"/> namespace="&mxsl;/example/vocab"> <r:Data xsi:type="xs:string"> <copy-of select="$name/node()"/> <copy-of select="$bname/node()"/> </element> </r:Data> <element name="name" </r:slot> namespace="&mxsl;/example/vocab"> </r:Atom></r:Equivalent></for-each></r:Rulebase> <copy-of select="$bname/node()"/> </element> </ex:record> </r:Data> </r:Atom>
  23. 23. Overview of Infinitary Logic (I)● Given a base (finitary) language L● Parameter κ : cardinality of sequences of conjunctions and disjunctions, also cardinality of set of variable symbols ∧ j∈ J Φ j ∨ j∈ J Φ j ∣J∣<κ● Parameter λ : cardinality of sequences of quantifiers (λ <= κ) ● http://plato.stanford.edu/entries/logic-infinitary/
  24. 24. Overview of Infinitary Logic (II)● L(ω, ω) = L● L(ω1, ω) = countable sequences of “junctions” ● If L is FOL, L(ω1, ω) is complete* but not compact** [Skolem, 1920]● L(ω1, ω1) = countable sequences of quantifiers ● If L is FOL, L(ω1, ω1) is neither complete nor compact * ● Completeness is defined with respect to a deductive system that allows proofs of countable length, and assumes countable sets of axioms ** ● Compact means if every finite subset of a set of formulas has a model then the original set has a model
  25. 25. RuleML with MXSL Axiom Schemas● Assert/Rulebase/xsl:for-each –> L(ω, ω) –> complete, compact● Assert/Rulebase/{And, Or}/xsl:for-each ● Disallowing mapClosure on Assert or Rulebase, nor closure on And –> L(ω1, ω) -> complete, not compact* ● Allowing mapClosure on Assert or Rulebase, or closure on And –> L(ω1, ω1) -> neither complete nor compact* *Follows if RuleML is given FOL semantics, assumes countable literals
  26. 26. Infinitary Case: In practice● Nonliteral vocabulary is typically finite● Literals can be introduced only as needed● Consider the captured string axiom ● One binding needed for each nonliteral in vocabulary ● (= (a) a) is discarded by the semantics if "a" is not in the vocabulary● So finite model property can be retained even with MXSL axiom schemas
  27. 27. Extensions: xsl:for-each/Query<xsl:for-each ...> <Query> <Atom><Rel>P</Rel> <Ind> <xsl:attribute name="type"> <xsl:copy-of select="$typeval/node()"/> ● Interpret as implicit disjunction of multiple queries ● Success = inconsistency of rulebase appended with negations of query (Rulebase/xsl:for-each/Neg) - L(ω, ω) ● Bindings are lost – extended query capability is needed
  28. 28. Metalanguage Abstract Syntax● Grouping symbols entered as pairs through one command● Mirrors the structure of the output document.● Iteration command generates a set of sibling items based on a pattern, instantiated with parameters.● Text always added through a metalanguage command, implementing output-escaping of punctuation characters
  29. 29. MXSL: For CLIF<xsl:for-each select="$input/v:first/m:binding"> <xsl:variable name="stringParam" select="v:stringParam" xsi:type="xs:string"/> <xsl:call-template name="element-cl"> <xsl:with-param name="apply" select="="/> <xsl:with-param name="args"> <xsl:call-template name="element-cl"> <xsl:with-param name="apply"> <xsl:call-template name="element-squote"> <xsl:with-param name="arg" select="$stringParam/node()"/> </xsl:call-template> </xsl:with-param> </xsl:call-template> <xsl:call-template name="element-dquote"> <xsl:with-param name="arg" select="$stringParam/node()"/> </xsl:call-template> </xsl:with-param> </xsl:call-template></xsl:for-each>
  30. 30. MCLIF(mcltext captured-string-axiom (for-each (($stringParam xs:string)) ( = (apply (squote $stringParam)) (dquote $stringParam )) ) )
  31. 31. Conclusions● MXSL: a (small) subset of the XSLT language, which can be used as a syntactic metalanguage for XML-based KR languages● MXSL expresses ● axiom schemas ● semantics of structured data ● generalized queries.● Paradigm for non-XML-based formats● Future investigations: reasoning

×