cs 6975 web semantics normalizers for ruleml 1.0 in xslt 2.0
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 PresentationTRANSCRIPT
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
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
Introduction•Work Flow diagram:
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>
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>
PHASE 1
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.
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
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>
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.
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.
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.
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>
Phase 1: Example <Equal>
Test Case ResultsRelaxed: Normalized:
Test Case ResultsPartially Normalized: Normalized:
Test Case ResultsPartially Normalized: Normalized:
Test Case ResultsFully Normalized: Normalized:
PHASE 2 Canonical Ordering
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>
Phase 2: <Implies> Example
Phase 2: <Implies> Example (cont.)
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>
Phase 2: <Atom> Example (cont.)
Before normalization:
After normalization:
PHASE 3 Default Values
Treatment of attributes with default values
Remain the original instinct of input
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>
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
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.
ResultsRuleml File After normalized:
PHASE 4 Pretty Print
Pretty Print•Output RuleML nicely•Comments
•For some tags we don’t want a new line
Pretty Print – How?•
•Variables and params▫ ▫ ▫
Pretty Print – Outline
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/