Observations about the semantics (was Re: One way to define the MCE semantics: XSLT)
MURATA Makoto
eb2m-mrt at asahi-net.or.jp
Sun Apr 15 18:05:23 CEST 2012
Dear colleagues,
Let me explain observations behind the XSLT stylesheet I distributed.
1) Removing nodes
An element (together with its attributes and content) is removed if (1) its
namespace is ignorable and not understood, and (2) this element is not
a decendant of a frozen (i.e., app-defined ext) element. (What happens
when a frozen elem is ignorable? I suppose it is frozen.)
An attribute is removed if (1) its namespace is ignorable and not understood
and (2) this attribute does not belong to a decendant of a frozen element.
A Choice element (together with its attributes and content) is removed if (1)
either its elder-sibling Choice is selected or one of the namespaces specified
by @Requires is not understood, and (2) this element is not a decendant of
a frozen element.
A Fallback element (together with its attributes and content) is removed if (1)
its elder-sibling Choice is selected and (2) this element is not a decendant of
a frozen element.
AlternateContent elements (not including their descendant elements) are removed.
2) Freezing nodes
An element (together with its attributes and content) is frozen if it is an
application-defined extension element and it is not a descendant of a
removed element.
--
Praying for the victims of the Japan Tohoku earthquake
Makoto
2012/4/12 MURATA Makoto <eb2m-mrt at asahi-net.or.jp>:
> Dear colleagues,
>
> I have been wondering how the semantics of MCE should be
> specified.
>
> Here is one way: a normative XSLT stylesheet. I am not saying that this
> is the best approach, but it at least deserves to be considered.
>
> This XSLT stylesheet uses four extension functions:
> me:frozen, me:ignored, me:selectable, and me:understood.
>
> Let me:frozen be an XPath extension function such that
> me:frozen(node) evalutes to true iff the node is an extension
> extension element.
>
> Let me:ignored be an XPath extension function such that
> me:ignored(node) evalutes to true iff the node is an element or
> attribute whose namespace is ignorable and non-understood.
>
> let me:selectable be an XPath extension function such that
> me:selectable(node) evalutes to true iff (1) this node is a Choice
> element and each of the namespace specified by the Requires attribute
> of this node is understood or (2) this node is a
> Fallback element.
>
> Let me:understood be an XPath extension function such that
> me:understood(string) evaluates to true iff the string is a white-space
> delimited list of understood namespaces. Observe that me:undersood("")
> is true.
>
> Note: me:ignored, me:selectable, me:understood require the
> configuration (i.e., a
> set of understood namespaces) as an environment, while me:frozen does
> not.
>
>
> <?xml version="1.0" encoding="UTF-8"?>
> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
> xmlns:me="http://purl.oclc.org/ooxml/markup-compatibility/extension-function"
> xmlns:mce="http://schemas.openxmlformats.org/markup-compatibility/2006"
> version="1.0">
>
> <xsl:template match="*[me:frozen(.)]">
> <xsl:copy-of select="."/>
> </xsl:template>
>
> <xsl:template match="*[me:ignored(.)]"/>
> <xsl:template match="@*[me:ignored(.)]"/>
>
> <xsl:template match="mce:AlternateContent">
> <xsl:for-each select="mce:Choice | mce:Fallback">
> <xsl:if test="me:selectable(.) and
> not(me:selectable(preceding-sibling::mce:Choice))">
> <xsl:apply-templates select="*"/>
> </xsl:if>
> </xsl:for-each>
> </xsl:template>
>
>
> <xsl:template match="*">
> <xsl:choose>
> <xsl:when test="me:understood(namespace-uri(.))">
> <xsl:copy>
> <xsl:apply-templates
> select="*|@*|processing-instruction()|comment()|text()"/>
> </xsl:copy>
> </xsl:when>
> <xsl:otherwise>
> <xsl:message terminate="yes">Non-understood namespace
> occurred</xsl:message>
> </xsl:otherwise>
> </xsl:choose>
> </xsl:template>
>
> <xsl:template match="@mce:MustUnderstand[not(me:understood(string(.)))]">
> <xsl:message terminate="yes">Non-understood namespace
> specified by @MustUnderstand</xsl:message>
> </xsl:template>
>
> <xsl:template match="@*">
> <xsl:choose>
> <xsl:when test="me:understood(namespace-uri(.))">
> <xsl:copy/>
> </xsl:when>
> <xsl:otherwise>
> <xsl:message terminate="yes">Non-understood namespace
> occurred</xsl:message>
> </xsl:otherwise>
> </xsl:choose>
> </xsl:template>
>
> <xsl:template match="text()|processing-instruction()|comment()">
> <xsl:copy/>
> </xsl:template>
> </xsl:stylesheet>
>
> P.S. I am now wondering what happens when an application-defined extension
> element belongs to a non-understood and non-ignorable namespace. Frozen
> or discarded?
>
> P.S. I suppose that @MustUnderstood cannot be specified by
> mce:AlternateContent,
> mce:Choice, or mce:Fallback.
>
> --
>
> Praying for the victims of the Japan Tohoku earthquake
>
> Makoto
More information about the sc34wg4
mailing list