XML tolerance of WSH engine 
Author Message
 XML tolerance of WSH engine

On one hand its nice to see how tolerant the WSH engine is about violation
of XML wellformedness rules.

On the other hand its really bad, because processing of .ws-files with XML
tools is made impossible, since the WSH engine wont accept CDATA-sections.

Will this change in the final release?

Ralf



Thu, 07 Feb 2002 03:00:00 GMT  
 XML tolerance of WSH engine
The WSH engine (which I will assume you mean to refer to wscript.exe) does _not_
handle the XML parsing .  The parser is scrobj.dll, the same as for .wsc files.

In any case, CDATA sections _are_ supported, but you _must_ include the xml
directive:

<?XML version="1.0" ?>

This also tightens the rules applied by the parser, though I haven't seen
anything in print (or online) as to what the exact distinction is between
"strict" (with the directive) and "loose" (without it).  If there were a public
DTD, one could sort of figure this out for oneself.  But the DTD is effectively
implemented in logic internal to scrobj.dll.  Even in "strict" mode you can get
away with plenty of "slop", even coding things that are total nonsense.

For example, the following runs just fine, even though there's no such thing as
a blahblah attribute on the <job> element, and certainly no such thing as a
<myelement> element ;-)

<?xml version="1.0" ?>
<?job error="true" debug="true" ?>
<job blahblah="true">
<myelement>
hello world
</myelement>
<script language="VBScript">
<![CDATA[
  msgbox "hello"
]]>
</script>
</job>

Seems to me that the "strict" rules are still pretty "loose", in fact too loose.

Of course, this a somewhat nonsensical example.  But I can easily imagine a more
realistic scenario of misspelled attribute names or even element names (as long
as the closing tag is misspelled in the same way as well) being tolerated when
(IMO) they should not be.

--
Michael Harris


| On one hand its nice to see how tolerant the WSH engine is about violation
| of XML wellformedness rules.
|
| On the other hand its really bad, because processing of .ws-files with XML
| tools is made impossible, since the WSH engine wont accept CDATA-sections.
|
| Will this change in the final release?
|
| Ralf
|
|



Thu, 07 Feb 2002 03:00:00 GMT  
 XML tolerance of WSH engine

Quote:
> This also tightens the rules applied by the parser, though I haven't seen
> anything in print (or online) as to what the exact distinction is between
> "strict" (with the directive) and "loose" (without it).  If there were a
public
> DTD, one could sort of figure this out for oneself.  But the DTD is
effectively
> implemented in logic internal to scrobj.dll.  Even in "strict" mode you
can get
> away with plenty of "slop", even coding things that are total nonsense.

Hi Michael,

Yes, it is still pretty "loose". One thing it does do is make everything
case sensitive (or so I'm lead to believe).

A funny thing I found (and posted several months ago) was that inside a
<method> element, you could call your parameters elements anything - e.g.
<foofoo /> - and it wouldn't complain ;-)

Peter

--
Peter J. Torr - Microsoft Windows Script Program Manager

Please do not e-mail me with questions - post them to this
newsgroup instead. Thankyou!



Thu, 07 Feb 2002 03:00:00 GMT  
 XML tolerance of WSH engine
"Strict" also requires attribute values to be quoted...

E.G.,

<job blahblah="true"> is OK

<job blahblah=true> is NOT-OK for "strict" but works for "loose" rules...

--
Michael Harris





| > This also tightens the rules applied by the parser, though I haven't seen
| > anything in print (or online) as to what the exact distinction is between
| > "strict" (with the directive) and "loose" (without it).  If there were a
| public
| > DTD, one could sort of figure this out for oneself.  But the DTD is
| effectively
| > implemented in logic internal to scrobj.dll.  Even in "strict" mode you
| can get
| > away with plenty of "slop", even coding things that are total nonsense.
|
| Hi Michael,
|
| Yes, it is still pretty "loose". One thing it does do is make everything
| case sensitive (or so I'm lead to believe).
|
| A funny thing I found (and posted several months ago) was that inside a
| <method> element, you could call your parameters elements anything - e.g.
| <foofoo /> - and it wouldn't complain ;-)
|
| Peter
|
| --
| Peter J. Torr - Microsoft Windows Script Program Manager

| Please do not e-mail me with questions - post them to this
| newsgroup instead. Thankyou!
|
|



Thu, 07 Feb 2002 03:00:00 GMT  
 XML tolerance of WSH engine
Eberhard,

Cool ;-)... It works!

There was one very small error in the DTD:

<!ELEMENT reference  (#PCDATA>

needs a closing )

<!ELEMENT reference  (#PCDATA)>

Here's a vbscript I used to drive the validation rather than download
xmlint.exe:

set xml = createobject("microsoft.xmldom")
successful = xml.load("C:\Scripts\xmldtd\test_validate.ws")
if successful then
  msgbox "no errors"
else
  msgbox "parseError.reason = " & xml.parseError.reason & vbcrlf _
       & " parseError.srcText = " & xml.parseError.srcText
end if

Here's the .ws file I "validated":

<?xml version="1.0" ?>
<!DOCTYPE job SYSTEM "C:\Scripts\xmldtd\wscript.dtd">
<job>
<script language="VBScript">
</script>
</job>

If I mess with _anything_, change case of element and/or attribute names,
make up (or misspell) names, etc., the validation fails.

It ignores <?xml ... ?> and <?job ...  ?> directives, but will error on
<?XML ... ?> because xml is reserved and if used must be lower case.

One thing to note is that this independent validation is _always_ strict.
You can't get away with any of the slop that scrobj.dll will allow (with or
without the <?XML ... ?> directive)!

Here's a suggestion (which I'll probably do for myself):

To avoid having to embed the <!DOCTYPE ... > in the file to be validated,
I'll probably enhance my validation driver to read the file to be validated
as text, determine the root element name (component, package, or job) and
inserted the <!DOCTYPE ... > in the right place and use loadXML instead of
load.

I'll also probably add command line support so I can add the validater as an
Explorer context menu command.

If I come across any other problems with the DTD, I'll let everyone know.
Hopefully someone else will use the DTD.  I don't have any very complicated
xml-based scripts or components yet.

Thanks, Eberhard ;-)

--
Michael Harris


| Michael,
|
| exactly for the same reason I just wrote an experimental DTD for
validating
| WSC, WS ... files. Unfortunately
| one has to insert a <!DOCTYPE ...> statement for validation only.
|
| I tried to collect all informations available in order to have kind of a
| short reference
| for all xml related stuff in one place. Now, I would like to ask if anyone
| could run it against some scripts in order to see that the DTD is correct
/
| complete.
|
| The wscript.dtd is attached. The header contains a short 'usage' section.
|
| Regards,
|
| Eberhard Lutz
|
|


| > "Strict" also requires attribute values to be quoted...
| >
| > E.G.,
| >
| > <job blahblah="true"> is OK
| >
| > <job blahblah=true> is NOT-OK for "strict" but works for "loose"
rules...
| >
| >
| > --
| > Michael Harris
| >
| >
| >




| > | > This also tightens the rules applied by the parser, though I haven't
| seen
| > | > anything in print (or online) as to what the exact distinction is
| between
| > | > "strict" (with the directive) and "loose" (without it).  If there
were
| a
| > | public
| > | > DTD, one could sort of figure this out for oneself.  But the DTD is
| > | effectively
| > | > implemented in logic internal to scrobj.dll.  Even in "strict" mode
| you
| > | can get
| > | > away with plenty of "slop", even coding things that are total
| nonsense.
| > |
| > | Hi Michael,
| > |
| > | Yes, it is still pretty "loose". One thing it does do is make
everything
| > | case sensitive (or so I'm lead to believe).
| > |
| > | A funny thing I found (and posted several months ago) was that inside
a
| > | <method> element, you could call your parameters elements anything -
| e.g.
| > | <foofoo /> - and it wouldn't complain ;-)
| > |
| > | Peter
| > |
| > | --
| > | Peter J. Torr - Microsoft Windows Script Program Manager

| > | Please do not e-mail me with questions - post them to this
| > | newsgroup instead. Thankyou!
| > |
| > |
| >
| >
|
|
|



Sun, 10 Feb 2002 03:00:00 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Tolerance in Expression [comparison]

2. problems with Access jet engine, Vbscript, wsh script - help

3. WSH engine on a floppy disk?

4. REXX engine(s) for WSH

5. Jet Engine, Vbscript, Wsh problems - help

6. Tcl WSH Scripting Engine

7. WSH Engine Install

8. WSH Settings File and Script Engine

9. Using XML with WSH

10. Frustrated with XML DOM in JScript (WSH)

11. WSH and XML

12. XML and WSH and type libs

 

 
Powered by phpBB® Forum Software