Re: Macro processor workaround for Schematron 1.6 with XT
Oliver Becker <[email protected]> Fri, 26 Sep 2003 11:24:23 +0200 (MEST)
| Newsgroups | gmane.text.xml.schematron |
|---|---|
| Message-ID | <[email protected]> |
Hi Rick,
> I have found that the macro pre-processor for Schematron 1.6 (typically
> called iso-pre-pro.xsl)
> has a problem when running with XT: XT's name() seems to strip out
> prefixes. So the fix
> to the preprocessor stylesheet is to add a default declaration
> xmlns="http://www.ascc.net/xml/schematron"
>
> For the record, I have attached it. This is the preprocessor that
> provides the abstract patterns
> function.
I don't understand why you're always using
<xslt:element name="{name()}">
That means: create an element with the same name as the current element.
There's nothing said about namespaces (which apparently means: create this
element with the current namespaces in-scope in the stylesheet). This is
error-prone because you cannot be sure that in the Schematron schema the
same namespace declarations exist as in this stylesheet (the macro processor).
For example someone might choose strn instead of sch as the prefix.
You want to create a copy of the current element, don't you?
I believe a better way is simply an <xslt:copy>.
(Hopefully you don't need the XT fix then.)
The second thing I'm wondering about is this one:
<xslt:template match="*" >
<xslt:if test="local-name()='schema'"> <!-- for XT -->
<xslt:attribute name="sch:dummy" value="dummy" />
</xslt:if>
<xslt:element name="{name()}" >
...
This should result in an error: you can't create an attribute *before*
creating the element.
Then again, the whole construct
<xslt:element name="{name()}" >
<xslt:for-each select="@*">
<xslt:attribute name="{name()}">
<xslt:value-of select="."/>
</xslt:attribute>
</xslt:for-each>
<xslt:apply-templates select="*|text()"/>
</xslt:element>
can be written much more simple and clear (in my eyes) as
<xslt:copy>
<xslt:copy-of select="@*" />
<xslt:apply-templates /> <!-- no need for select="*|text()" -->
</xslt:copy>
Or do I miss something (and your usage of xslt:element and xslt:attribute
is important for some reason)?
Cheers,
Oliver
/-------------------------------------------------------------------\
| ob|do Dipl.Inf. Oliver Becker |
| --+-- E-Mail: [email protected] |
| op|qo WWW: http://www.informatik.hu-berlin.de/~obecker |
\-------------------------------------------------------------------/
-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf