cs 6975 web semantics normalizers for ruleml 1.0 in xslt 2.0

34
CS 6975 Web Semantics Normalizers for RuleML 1.0 in XSLT 2.0 Nada Alsalmi Leah Bidlake Ao Cheng Thea Gegenberg Emily Wilson Instructor: Dr. Harold Boley Advisor: Dr. Tara Athan

Upload: talasi

Post on 16-Mar-2016

53 views

Category:

Documents


2 download

DESCRIPTION

CS 6975 Web Semantics Normalizers for RuleML 1.0 in XSLT 2.0. Nada Alsalmi ‍Leah Bidlake ‍ Ao Cheng ‍ Thea Gegenberg ‍Emily Wilson Instructor: Dr. Harold Boley Advisor: Dr. Tara Athan. Overview. Introduction Comparison to previous Normalizer Our 4-Phase Normalizer: - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: CS 6975 Web Semantics Normalizers for RuleML 1.0 in XSLT 2.0

CS 6975 Web SemanticsNormalizers for RuleML 1.0 in XSLT 2.0Nada Alsalmi Leah Bidlake Ao Cheng Thea Gegenberg Emily WilsonInstructor: Dr. Harold BoleyAdvisor: Dr. Tara Athan

Page 2: CS 6975 Web Semantics Normalizers for RuleML 1.0 in XSLT 2.0

Overview•Introduction•Comparison to previous Normalizer•Our 4-Phase Normalizer:

▫Phase 1 – Adding Role Tags▫Phase 2 – Canonical Ordering▫Phase 3 – Making attribute default values

explicit▫Phase 4 – Pretty Print

•Demo

Page 3: CS 6975 Web Semantics Normalizers for RuleML 1.0 in XSLT 2.0

Introduction•Work Flow diagram:

Page 4: CS 6975 Web Semantics Normalizers for RuleML 1.0 in XSLT 2.0

Multiple Phases within a Single Stylesheet•Within a single stylesheet, a pipeline is

expressed as a series of variables:<xsl:variable name="phase-1-output"><xsl:apply-templates select="/"

mode="phase-1"/></xsl:variable><xsl:variable name="phase-2-output"><xsl:apply-templates select="$phase-1-

output" mode="phase-2"/> </xsl:variable>

Page 5: CS 6975 Web Semantics Normalizers for RuleML 1.0 in XSLT 2.0

Comparison to Derek’s & David’s Normalizer• Performed transformation in 1 Pass/Phase

<xsl:template match="*"> <xsl:choose> <xsl:when test="name(.)='Implies'"> … </xsl:when> <xsl:when test="name(.)='Expr'"> … </xsl:choose><xsl:template match>

Page 6: CS 6975 Web Semantics Normalizers for RuleML 1.0 in XSLT 2.0

PHASE 1

Page 7: CS 6975 Web Semantics Normalizers for RuleML 1.0 in XSLT 2.0

RuleML 0.91 to 1.0•All references for namespace and schema

locations changed to: http://www.ruleml.org/1.0/xsd

•Output from style sheet has RuleML Version 1.0 as default namespace.

Page 8: CS 6975 Web Semantics Normalizers for RuleML 1.0 in XSLT 2.0

RuleML 0.91 to 1.0Changes to names of role tags:•Children of <Implies>

▫Role tag <head> replaced with <then>▫Role tag <body> replace with <if>

•Children of <Equal>▫Role tag <lhs> replaced with <left>▫Role tag <rhs> replace with <right>

•Name of interpretation attribute:▫@in changed to @per

Page 9: CS 6975 Web Semantics Normalizers for RuleML 1.0 in XSLT 2.0

RuleML 0.91 to 1.0 – Other Changes•Webizing attribute:

▫@uri changed to @iri•Name of type tag for unified term:

▫<Hterm> changed to <Uniterm>•Name of type tag for constant term:

▫<Con> changed to <Const>•Content of <RuleML>

▫Role tag <act> wraps all content of <RuleML>

Page 10: CS 6975 Web Semantics Normalizers for RuleML 1.0 in XSLT 2.0

Phase 1 – Add Missing Edge Stripes•Edge is also referred to as role tag or

method tag.•Match the elements using the parent tag.•Determine if the children were already

wrapped with the appropriate tag.•Wrap the ‘naked’ children with the

appropriate role tag.•For some elements an index attribute was

also added.

Page 11: CS 6975 Web Semantics Normalizers for RuleML 1.0 in XSLT 2.0

Phase 1•Each time an element was matched there

was a test to determine if the role tags were already present for any or all of the children.

•In some cases the children may already be wrapped in role tags but in a different order, which had to be tested for.

•Test cases developed including: relaxed, partially normalized and fully normalized.

Page 12: CS 6975 Web Semantics Normalizers for RuleML 1.0 in XSLT 2.0

Phase 1•Adding missing stripes to Implies and Entails

– difficult because of the number of possibilities of missing <if>, <then> stripes.

•As suggested by Tara Athan, our advisor, this was simplified by assuming that the <if> and <then> are in canonical position already if stripes are skipped.

Page 13: CS 6975 Web Semantics Normalizers for RuleML 1.0 in XSLT 2.0

Phase 1 – Example <Equal>•1st child wrapped with <left>•2nd child wrapped with <right>•Check for partially normalized:

▫If the 1st child was already wrapped with <right> then the 2nd child has to be wrapped with <left>

Page 14: CS 6975 Web Semantics Normalizers for RuleML 1.0 in XSLT 2.0

Phase 1: Example <Equal>

Page 15: CS 6975 Web Semantics Normalizers for RuleML 1.0 in XSLT 2.0

Test Case ResultsRelaxed: Normalized:

Page 16: CS 6975 Web Semantics Normalizers for RuleML 1.0 in XSLT 2.0

Test Case ResultsPartially Normalized: Normalized:

Page 17: CS 6975 Web Semantics Normalizers for RuleML 1.0 in XSLT 2.0

Test Case ResultsPartially Normalized: Normalized:

Page 18: CS 6975 Web Semantics Normalizers for RuleML 1.0 in XSLT 2.0

Test Case ResultsFully Normalized: Normalized:

Page 19: CS 6975 Web Semantics Normalizers for RuleML 1.0 in XSLT 2.0

PHASE 2 Canonical Ordering

Page 20: CS 6975 Web Semantics Normalizers for RuleML 1.0 in XSLT 2.0

Phases 2: Canonical Order•Output Schema used to infer canonical

ordering•e.g. 

<xsl:template match="Implies" mode="phase-2">    <xsl:copy>     <xsl:apply-templates select="oid" mode="phase-2"/>     <xsl:apply-templates select="if" mode="phase-2"/>     <xsl:apply-templates select="then" mode="phase-2"/>     <xsl:apply-templates select="@*|*[name(.)!='oid' and name(.)!='if' and name(.) != 'then']" mode="phase-2"/>    </xsl:copy>     </xsl:template>

Page 21: CS 6975 Web Semantics Normalizers for RuleML 1.0 in XSLT 2.0

Phase 2: <Implies> Example

Page 22: CS 6975 Web Semantics Normalizers for RuleML 1.0 in XSLT 2.0

Phase 2: <Implies> Example (cont.)

Page 23: CS 6975 Web Semantics Normalizers for RuleML 1.0 in XSLT 2.0

Phase 2: <Atom> Example<xsl:template match="Atom" mode="phase-2"> <xsl:copy> <xsl:apply-templates select="op" mode="phase-2"/> <xsl:apply-templates select="arg" mode="phase-2"/> <xsl:apply-templates select="slot" mode="phase-2"/> <xsl:apply-templates select="@*|*[name(.)!='op' and

name(.)!='arg' and name(.) != 'slot']" mode="phase-2"/></xsl:copy> </xsl:template>

Page 24: CS 6975 Web Semantics Normalizers for RuleML 1.0 in XSLT 2.0

Phase 2: <Atom> Example (cont.)

Before normalization:

After normalization:

Page 25: CS 6975 Web Semantics Normalizers for RuleML 1.0 in XSLT 2.0

PHASE 3 Default Values

Treatment of attributes with default values

Remain the original instinct of input

Page 26: CS 6975 Web Semantics Normalizers for RuleML 1.0 in XSLT 2.0

Modes•Phase 1, Phase2, Phase3 are

independently implemented.•Use the feature of “mode” from XSLT

2.0 Format the same Data differently in different

Places XSLT<xsl:apply-templates>Element<xsl:apply-templates select=“XPath expression" mode="name">

  <!-- Content:(xsl:sort|xsl:with-param)* -->

</xsl:apply-templates>

Page 27: CS 6975 Web Semantics Normalizers for RuleML 1.0 in XSLT 2.0

Default Values

• @mapMaterial ( yes | no )• @material ( yes | no )• @mapDirection( bidirectional | forward | backward )• @direction( bidirectional | forward | backward )• @oriented ( no | yes )• @val ( 0.. | 1 )• @per ( no | yes )

List

Page 28: CS 6975 Web Semantics Normalizers for RuleML 1.0 in XSLT 2.0

Problems• Then oxygen seemed to automatically put in all possible

attributes listed with their default values. If list all the schemas in the ruleml file, i.e. <RuleMLxmlns="http://www.ruleml.org/1.0/xsd"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://www.ruleml.org/1.0/xsd http://www.ruleml.org/1.0/xsd/datalog.xsd">

• Oxygen explicit copying of default attributes won’t happen if you do delete the attributes of the RuleML tag that specify the schema.

Page 29: CS 6975 Web Semantics Normalizers for RuleML 1.0 in XSLT 2.0

ResultsRuleml File After normalized:

Page 30: CS 6975 Web Semantics Normalizers for RuleML 1.0 in XSLT 2.0

PHASE 4 Pretty Print

Page 31: CS 6975 Web Semantics Normalizers for RuleML 1.0 in XSLT 2.0

Pretty Print•Output RuleML nicely•Comments

•For some tags we don’t want a new line

Page 32: CS 6975 Web Semantics Normalizers for RuleML 1.0 in XSLT 2.0

Pretty Print – How?•

•Variables and params▫ ▫ ▫

Page 33: CS 6975 Web Semantics Normalizers for RuleML 1.0 in XSLT 2.0

Pretty Print – Outline

Page 34: CS 6975 Web Semantics Normalizers for RuleML 1.0 in XSLT 2.0

Final Demo•http://www.w3.org/2005/08/online_xslt/•Normalizer:

http://v37s3b4h7dn47s37hg1br4h7rs7n3du7s8nu.unbf.ca/~lbidlak1/100relaxed-to-normal.xslt

•Handout Website: http://v37s3b4h7dn47s37hg1br4h7rs7n3du7s8nu.unbf.ca/~lbidlak1/