Question about a warning message

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Question about a warning message

Radu Coravu
Hi,

When publishing some DITA content one of the DITA Open Toolkit stages
which applies Saxon 9.5.0.2 on a merged XML document reports a warning
coming from Saxon:

>
> transform.topic2fo.main:
>      [xslt] Processing D:\projects\eXml\samples\dita\flowers\temp\pdf\stage1a.xml to D:\projects\eXml\samples\dita\flowers\temp\pdf\stage2.fo
>      [xslt] Loading stylesheet D:\projects\eXml\frameworks\dita\DITA-OT\plugins\org.dita.pdf2\xsl\fo\topic2fo_shell_xep.xsl
>      [xslt] : Warning! The source document is in no namespace, but the template rules all expect elements in a namespace

I do not know what this warning message means, it is probably given by
Saxon:

> Warning! The source document is in no namespace, but the template rules all expect elements in a namespace

Indeed the XML has no namespace but the template rules usually apply
something like:

> <xsl:template match="*" mode="use-abbreviated-form" as="xs:boolean">

So to what xsl:template does the warning message refer to? The XSLs are
quite complex and interlinked.

--
Regards,
Radu

Radu Coravu
<oXygen/>  XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com

------------------------------------------------------------------------------
This SF.net email is sponsored by Windows:

Build for Windows Store.

http://p.sf.net/sfu/windows-dev2dev
_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help 
Reply | Threaded
Open this post in threaded view
|

Re: Question about a warning message

Michael Kay
This warning message was introduced in Saxon 9.5.

It's designed to catch the common beginner's error of having a source document of the form

<a xmlns="http://some.uri/">
  <b/>
  <c/>
</a>

and then doing

<xsl:template match="a">

and wondering why nothing matches. We see this so often, and it's so confusing for newbies, that we thought we ought to try and do something about it. But like any warning, there will inevitably be false positives.

The more common form of the warning is of course

The source document is in namespace " + uri + ", but all the template rules match elements in no namespace

and arguably the inverse message, which is the one you are reporting, is not justified.

The precise conditions for the message are:

* for the initial mode, consider all the template rules whose match pattern will only match elements in a particular namespace (that is, ignore patterns like match="*"), treating the no-namespace as a namespace

* if the set of "explicit namespaces" matched by these patterns is non-empty but does not include the namespace of the outermost element of the primary source document, produce the warning.

If we can identify scenarios that help to eliminate false positives while still catching the common elephant trap, then of course we can try and refine this.

Michael Kay
Saxonica


On 25 Jun 2013, at 08:59, Radu Coravu wrote:

> Hi,
>
> When publishing some DITA content one of the DITA Open Toolkit stages
> which applies Saxon 9.5.0.2 on a merged XML document reports a warning
> coming from Saxon:
>
>>
>> transform.topic2fo.main:
>>     [xslt] Processing D:\projects\eXml\samples\dita\flowers\temp\pdf\stage1a.xml to D:\projects\eXml\samples\dita\flowers\temp\pdf\stage2.fo
>>     [xslt] Loading stylesheet D:\projects\eXml\frameworks\dita\DITA-OT\plugins\org.dita.pdf2\xsl\fo\topic2fo_shell_xep.xsl
>>     [xslt] : Warning! The source document is in no namespace, but the template rules all expect elements in a namespace
>
> I do not know what this warning message means, it is probably given by
> Saxon:
>
>> Warning! The source document is in no namespace, but the template rules all expect elements in a namespace
>
> Indeed the XML has no namespace but the template rules usually apply
> something like:
>
>> <xsl:template match="*" mode="use-abbreviated-form" as="xs:boolean">
>
> So to what xsl:template does the warning message refer to? The XSLs are
> quite complex and interlinked.
>
> --
> Regards,
> Radu
>
> Radu Coravu
> <oXygen/>  XML Editor, Schema Editor and XSLT Editor/Debugger
> http://www.oxygenxml.com
>
> ------------------------------------------------------------------------------
> This SF.net email is sponsored by Windows:
>
> Build for Windows Store.
>
> http://p.sf.net/sfu/windows-dev2dev
> _______________________________________________
> saxon-help mailing list archived at http://saxon.markmail.org/
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/saxon-help 


------------------------------------------------------------------------------
This SF.net email is sponsored by Windows:

Build for Windows Store.

http://p.sf.net/sfu/windows-dev2dev
_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help 
Reply | Threaded
Open this post in threaded view
|

Re: Question about a warning message

Radu Coravu
Hi Michael,

Looking in the particular context of DITA, the DITA XML content is in no
namespace but it is possible that in some places there would be embedded
SVG or MathML elements (which have a namespace).
Most DITA XSLTs match "*[@class='...']" but there are some templates
which match something like "mathml:*". So this probably causes the warnings.

Usually when a developer sees a warning he tries to modify the code
(XSLs in this case) in some way in order to remove it.

But I think that the problem with such warnings is that there are legit
cases in which you cannot remove this warning no matter how you organize
your XSLs.
Ideally the warning would only be given only after all namespace
declarations have been collected from the XML document and compared with
the XSLT matches.

Regards,
Radu

Radu Coravu
<oXygen/>  XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com

On 6/25/2013 12:35 PM, Michael Kay wrote:

> This warning message was introduced in Saxon 9.5.
>
> It's designed to catch the common beginner's error of having a source document of the form
>
> <a xmlns="http://some.uri/">
>    <b/>
>    <c/>
> </a>
>
> and then doing
>
> <xsl:template match="a">
>
> and wondering why nothing matches. We see this so often, and it's so confusing for newbies, that we thought we ought to try and do something about it. But like any warning, there will inevitably be false positives.
>
> The more common form of the warning is of course
>
> The source document is in namespace " + uri + ", but all the template rules match elements in no namespace
>
> and arguably the inverse message, which is the one you are reporting, is not justified.
>
> The precise conditions for the message are:
>
> * for the initial mode, consider all the template rules whose match pattern will only match elements in a particular namespace (that is, ignore patterns like match="*"), treating the no-namespace as a namespace
>
> * if the set of "explicit namespaces" matched by these patterns is non-empty but does not include the namespace of the outermost element of the primary source document, produce the warning.
>
> If we can identify scenarios that help to eliminate false positives while still catching the common elephant trap, then of course we can try and refine this.
>
> Michael Kay
> Saxonica
>
>
> On 25 Jun 2013, at 08:59, Radu Coravu wrote:
>
>> Hi,
>>
>> When publishing some DITA content one of the DITA Open Toolkit stages
>> which applies Saxon 9.5.0.2 on a merged XML document reports a warning
>> coming from Saxon:
>>
>>>
>>> transform.topic2fo.main:
>>>      [xslt] Processing D:\projects\eXml\samples\dita\flowers\temp\pdf\stage1a.xml to D:\projects\eXml\samples\dita\flowers\temp\pdf\stage2.fo
>>>      [xslt] Loading stylesheet D:\projects\eXml\frameworks\dita\DITA-OT\plugins\org.dita.pdf2\xsl\fo\topic2fo_shell_xep.xsl
>>>      [xslt] : Warning! The source document is in no namespace, but the template rules all expect elements in a namespace
>>
>> I do not know what this warning message means, it is probably given by
>> Saxon:
>>
>>> Warning! The source document is in no namespace, but the template rules all expect elements in a namespace
>>
>> Indeed the XML has no namespace but the template rules usually apply
>> something like:
>>
>>> <xsl:template match="*" mode="use-abbreviated-form" as="xs:boolean">
>>
>> So to what xsl:template does the warning message refer to? The XSLs are
>> quite complex and interlinked.
>>
>> --
>> Regards,
>> Radu
>>
>> Radu Coravu
>> <oXygen/>  XML Editor, Schema Editor and XSLT Editor/Debugger
>> http://www.oxygenxml.com
>>
>> ------------------------------------------------------------------------------
>> This SF.net email is sponsored by Windows:
>>
>> Build for Windows Store.
>>
>> http://p.sf.net/sfu/windows-dev2dev
>> _______________________________________________
>> saxon-help mailing list archived at http://saxon.markmail.org/
>> [hidden email]
>> https://lists.sourceforge.net/lists/listinfo/saxon-help
>
>
> ------------------------------------------------------------------------------
> This SF.net email is sponsored by Windows:
>
> Build for Windows Store.
>
> http://p.sf.net/sfu/windows-dev2dev
> _______________________________________________
> saxon-help mailing list archived at http://saxon.markmail.org/
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/saxon-help
>


--


------------------------------------------------------------------------------
This SF.net email is sponsored by Windows:

Build for Windows Store.

http://p.sf.net/sfu/windows-dev2dev
_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help 
Reply | Threaded
Open this post in threaded view
|

Re: Question about a warning message

Dave Pawson-2
Could the phrasing be such as to either
1. Warn the newbie, as Mike suggests
2. Re-assure the more ns familiar user that he/she has done the right thing?

regards

On 25 June 2013 12:01, Radu Coravu <[hidden email]> wrote:

> Hi Michael,
>
> Looking in the particular context of DITA, the DITA XML content is in no
> namespace but it is possible that in some places there would be embedded
> SVG or MathML elements (which have a namespace).
> Most DITA XSLTs match "*[@class='...']" but there are some templates
> which match something like "mathml:*". So this probably causes the warnings.
>
> Usually when a developer sees a warning he tries to modify the code
> (XSLs in this case) in some way in order to remove it.
>
> But I think that the problem with such warnings is that there are legit
> cases in which you cannot remove this warning no matter how you organize
> your XSLs.
> Ideally the warning would only be given only after all namespace
> declarations have been collected from the XML document and compared with
> the XSLT matches.
>
> Regards,
> Radu
>
> Radu Coravu
> <oXygen/>  XML Editor, Schema Editor and XSLT Editor/Debugger
> http://www.oxygenxml.com
>
> On 6/25/2013 12:35 PM, Michael Kay wrote:
>> This warning message was introduced in Saxon 9.5.
>>
>> It's designed to catch the common beginner's error of having a source document of the form
>>
>> <a xmlns="http://some.uri/">
>>    <b/>
>>    <c/>
>> </a>
>>
>> and then doing
>>
>> <xsl:template match="a">
>>
>> and wondering why nothing matches. We see this so often, and it's so confusing for newbies, that we thought we ought to try and do something about it. But like any warning, there will inevitably be false positives.
>>
>> The more common form of the warning is of course
>>
>> The source document is in namespace " + uri + ", but all the template rules match elements in no namespace
>>
>> and arguably the inverse message, which is the one you are reporting, is not justified.
>>
>> The precise conditions for the message are:
>>
>> * for the initial mode, consider all the template rules whose match pattern will only match elements in a particular namespace (that is, ignore patterns like match="*"), treating the no-namespace as a namespace
>>
>> * if the set of "explicit namespaces" matched by these patterns is non-empty but does not include the namespace of the outermost element of the primary source document, produce the warning.
>>
>> If we can identify scenarios that help to eliminate false positives while still catching the common elephant trap, then of course we can try and refine this.
>>
>> Michael Kay
>> Saxonica
>>
>>
>> On 25 Jun 2013, at 08:59, Radu Coravu wrote:
>>
>>> Hi,
>>>
>>> When publishing some DITA content one of the DITA Open Toolkit stages
>>> which applies Saxon 9.5.0.2 on a merged XML document reports a warning
>>> coming from Saxon:
>>>
>>>>
>>>> transform.topic2fo.main:
>>>>      [xslt] Processing D:\projects\eXml\samples\dita\flowers\temp\pdf\stage1a.xml to D:\projects\eXml\samples\dita\flowers\temp\pdf\stage2.fo
>>>>      [xslt] Loading stylesheet D:\projects\eXml\frameworks\dita\DITA-OT\plugins\org.dita.pdf2\xsl\fo\topic2fo_shell_xep.xsl
>>>>      [xslt] : Warning! The source document is in no namespace, but the template rules all expect elements in a namespace
>>>
>>> I do not know what this warning message means, it is probably given by
>>> Saxon:
>>>
>>>> Warning! The source document is in no namespace, but the template rules all expect elements in a namespace
>>>
>>> Indeed the XML has no namespace but the template rules usually apply
>>> something like:
>>>
>>>> <xsl:template match="*" mode="use-abbreviated-form" as="xs:boolean">
>>>
>>> So to what xsl:template does the warning message refer to? The XSLs are
>>> quite complex and interlinked.
>>>
>>> --
>>> Regards,
>>> Radu
>>>
>>> Radu Coravu
>>> <oXygen/>  XML Editor, Schema Editor and XSLT Editor/Debugger
>>> http://www.oxygenxml.com
>>>
>>> ------------------------------------------------------------------------------
>>> This SF.net email is sponsored by Windows:
>>>
>>> Build for Windows Store.
>>>
>>> http://p.sf.net/sfu/windows-dev2dev
>>> _______________________________________________
>>> saxon-help mailing list archived at http://saxon.markmail.org/
>>> [hidden email]
>>> https://lists.sourceforge.net/lists/listinfo/saxon-help
>>
>>
>> ------------------------------------------------------------------------------
>> This SF.net email is sponsored by Windows:
>>
>> Build for Windows Store.
>>
>> http://p.sf.net/sfu/windows-dev2dev
>> _______________________________________________
>> saxon-help mailing list archived at http://saxon.markmail.org/
>> [hidden email]
>> https://lists.sourceforge.net/lists/listinfo/saxon-help
>>
>
>
> --
>
>
> ------------------------------------------------------------------------------
> This SF.net email is sponsored by Windows:
>
> Build for Windows Store.
>
> http://p.sf.net/sfu/windows-dev2dev
> _______________________________________________
> saxon-help mailing list archived at http://saxon.markmail.org/
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/saxon-help



--
Dave Pawson
XSLT XSL-FO FAQ.
Docbook FAQ.
http://www.dpawson.co.uk

------------------------------------------------------------------------------
This SF.net email is sponsored by Windows:

Build for Windows Store.

http://p.sf.net/sfu/windows-dev2dev
_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help 
Reply | Threaded
Open this post in threaded view
|

Re: Question about a warning message

Michael Kay
In reply to this post by Radu Coravu

On 25 Jun 2013, at 12:01, Radu Coravu wrote:

> Hi Michael,
>
> Looking in the particular context of DITA, the DITA XML content is in no
> namespace but it is possible that in some places there would be embedded
> SVG or MathML elements (which have a namespace).
> Most DITA XSLTs match "*[@class='...']" but there are some templates
> which match something like "mathml:*". So this probably causes the warnings.

Yes,

Incidentally, I've been meaning for years to improve the template matching performance when there are lots of templates of the form match=*[predicate]. It can currently be very inefficient, compared with matching by element name.

>
> Usually when a developer sees a warning he tries to modify the code
> (XSLs in this case) in some way in order to remove it.

>
> But I think that the problem with such warnings is that there are legit
> cases in which you cannot remove this warning no matter how you organize
> your XSLs.
> Ideally the warning would only be given only after all namespace
> declarations have been collected from the XML document and compared with
> the XSLT matches.
>

We could try that. Certainly with a TinyTree, finding the total set of namespaces used can be done very easily. It's harder with other tree models.

There will still be false positives for other cases though, like a use case where the primary source document is a small catalog file in no namespace and the secondary source documents are in a namespace.

Another approach would be to output a warning only in the case where we get to the end of the transformation and every attempt to apply-templates to an element node has selected the built-in rules.

My basic premise is that people doing complicated things can cope with a false warning, while the hundreds of newbies who have no idea what a namespace is need some help.

Michael Kay
Saxonica


------------------------------------------------------------------------------
This SF.net email is sponsored by Windows:

Build for Windows Store.

http://p.sf.net/sfu/windows-dev2dev
_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help 
Reply | Threaded
Open this post in threaded view
|

Re: Question about a warning message

Michael Sokolov-2
On 6/25/13 7:41 AM, Michael Kay wrote:
> My basic premise is that people doing complicated things can cope with
> a false warning, while the hundreds of newbies who have no idea what a
> namespace is need some help. Michael Kay Saxonica
The usual approach to dealing with unwanted compiler warnings is to
provide users a pragma of some sort that can disable them.  That would
probably be a welcome thing for experts who know what they are doing,
and wouldn't obtrude on the newbies.  Feature request for:
<saxon:disable-warning code="unmatched-namespace" /> or something like that?

-Mike

------------------------------------------------------------------------------
This SF.net email is sponsored by Windows:

Build for Windows Store.

http://p.sf.net/sfu/windows-dev2dev
_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help