PocketIE and XSL

G

Guest

Guest
Archived from groups: microsoft.public.pocketpc (More info?)

hi there

I'm battling against the lack of documentation for PIE 2003, and wonder
if anyone has any idea about support for XSLT?

In particular, the "eXtensible" bit, I'd like to define new namespaces and
functions therein. Actually, the namespace bit isn't important :)

What documentation I've got suggests that PIE supports msxml2, which
means that <xsl:script implements-namespace="custom"> should allow
me to define and use functions like <xsl:value-of
select="custom:doThing()"/>

and, lo, it parses just fine which implies that the tag names are - at
least -
recognised by PIE but it utterly fails to recognise the namespace or
function
subsequently.

Can anyone verify that this isn't supported by PIE (wouldn't be surprised
but,
as it's an exception to the msxml2 rule, I am surprised it's not mentioned
in
those places where PIE limitations _are_ discussed)? Or can anyone help me
in finding ways to get this to work? It might just be that I've got the
blah:xmlns
declarations wrong for PIE, for instance.

Anyway, I'm pretty sure that I can live without it by trundling through the
DOM and doing text fixups as appropriate, but if I could build it into the
stylesheet directly, it would be many times less effort and much cleverer.

many thanks for any pointers - if anyone wants to start a pocketIE survivors
group, I'm in...


ed
 
G

Guest

Guest
Archived from groups: microsoft.public.pocketpc (More info?)

MSXML2 being so freaking old, it's hard to find proper documentation...
But, even msxml4.0 doesn't seem to like xsl:script (please correct me if I'm
wrong here) Try replacing xsl:script with msxml:script and declaring
xmlns:msxsl="urn:schemas-microsoft-com:xslt"

For example, the following should work:

<?xml version="1.0"?>
<xsl:stylesheet version="1.1"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt"
>

<xsl:template match="/">
<html><body>
<xsl:value-of select="custom:doThing()" />
</body></html>
</xsl:template>

<msxsl:script
implements-prefix="custom"
language="javascript">
<![CDATA[

function doThing() {
return "I did a Thing!";
}
]]>
</msxsl:script>


Andy.

"Ed Carter" <ed@springcorp.co.uk> wrote in message
news:%23CuUhSeFFHA.1084@tk2msftngp13.phx.gbl...
>
> hi there
>
> I'm battling against the lack of documentation for PIE 2003, and wonder
> if anyone has any idea about support for XSLT?
>
> In particular, the "eXtensible" bit, I'd like to define new namespaces and
> functions therein. Actually, the namespace bit isn't important :)
>
> What documentation I've got suggests that PIE supports msxml2, which
> means that <xsl:script implements-namespace="custom"> should allow
> me to define and use functions like <xsl:value-of
> select="custom:doThing()"/>
>
> and, lo, it parses just fine which implies that the tag names are - at
> least -
> recognised by PIE but it utterly fails to recognise the namespace or
> function
> subsequently.
>
> Can anyone verify that this isn't supported by PIE (wouldn't be surprised
> but,
> as it's an exception to the msxml2 rule, I am surprised it's not mentioned
> in
> those places where PIE limitations _are_ discussed)? Or can anyone help me
> in finding ways to get this to work? It might just be that I've got the
> blah:xmlns
> declarations wrong for PIE, for instance.
>
> Anyway, I'm pretty sure that I can live without it by trundling through
> the
> DOM and doing text fixups as appropriate, but if I could build it into the
> stylesheet directly, it would be many times less effort and much cleverer.
>
> many thanks for any pointers - if anyone wants to start a pocketIE
> survivors
> group, I'm in...
>
>
> ed
>
>
>
 
G

Guest

Guest
Archived from groups: microsoft.public.pocketpc (More info?)

On Fri, 18 Feb 2005 18:06:53 -0000, "Ed Carter" <ed@springcorp.co.uk>
wrote:


>many thanks for any pointers - if anyone wants to start a pocketIE survivors
>group, I'm in...
>
>
>ed

You're in good company if that's any help ;-)

Cheers - Neil
 
G

Guest

Guest
Archived from groups: microsoft.public.pocketpc,microsoft.public.pocketpc.developer (More info?)

Hi Andy

(cross posted to the developer group now, after an earlier slip of the
mouse. see the original post at the end or summarised as: "PocketIE",
"XSLT", "script" and "argh")

Thanks for this, it's more or less what I've been trying.

Here's some background on what I've discovered so far...

What I've got to work (in the way of general xslt transforms) depends
to a greater or lesser extent on the namespace declarations, for
even basic stuff. I'm using <XML> inline to hold data and stylesheet
and this stylesheet declaration works on pocketIE:

xmlns:xsl="uri:xsl"

but this one just renders the stylesheet to the page as if t'were html:

xmlns:xsl="http://www.w3.org/1999/XSL/Transform"

embedded script in msxml2 might or might not have been implemented
using <xsl:script> or <msxml:script>, I've tried both.

See: http://www.topxml.com/xsl/elmmsxml_script.asp which hints at
a change in tagname.


Now, the style sheet DOES parse ok with <[ms]xsl:script> tags in it,
so there is some knowledge of it in the xslt implementation in PIE,
but I just bump up against "unknown method" errors when I try
to use it. the non-standard namespace effect makes me cling
to the hope that it's just a matter of getting tags, etc, just so...

To my tiny mind the ability to add script to xslt is so fundamental
to getting the presentation layer right (just to do simple things like
transform date formats, etc, without a canonical list of <xsl:if>s),
that it _must_ be possible. they can't possibly have just left it out
when all the component functionality (scripting etc) is in place.

can they?

ed


"Andy Dadi" <adadi@online.microsoft.com> wrote in message
news:%233lgd8eFFHA.3840@tk2msftngp13.phx.gbl...
> MSXML2 being so freaking old, it's hard to find proper documentation...
> But, even msxml4.0 doesn't seem to like xsl:script (please correct me if
> I'm wrong here) Try replacing xsl:script with msxml:script and declaring
> xmlns:msxsl="urn:schemas-microsoft-com:xslt"
>
> For example, the following should work:
>
> <?xml version="1.0"?>
> <xsl:stylesheet version="1.1"
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
> xmlns:msxsl="urn:schemas-microsoft-com:xslt"
>>
>
> <xsl:template match="/">
> <html><body>
> <xsl:value-of select="custom:doThing()" />
> </body></html>
> </xsl:template>
>
> <msxsl:script
> implements-prefix="custom"
> language="javascript">
> <![CDATA[
>
> function doThing() {
> return "I did a Thing!";
> }
> ]]>
> </msxsl:script>
>
>
> Andy.
>
> "Ed Carter" <ed@springcorp.co.uk> wrote in message
> news:%23CuUhSeFFHA.1084@tk2msftngp13.phx.gbl...
>>
>> hi there
>>
>> I'm battling against the lack of documentation for PIE 2003, and wonder
>> if anyone has any idea about support for XSLT?
>>
>> In particular, the "eXtensible" bit, I'd like to define new namespaces
>> and
>> functions therein. Actually, the namespace bit isn't important :)
>>
>> What documentation I've got suggests that PIE supports msxml2, which
>> means that <xsl:script implements-namespace="custom"> should allow
>> me to define and use functions like <xsl:value-of
>> select="custom:doThing()"/>
>>
>> and, lo, it parses just fine which implies that the tag names are - at
>> least -
>> recognised by PIE but it utterly fails to recognise the namespace or
>> function
>> subsequently.
>>
>> Can anyone verify that this isn't supported by PIE (wouldn't be surprised
>> but,
>> as it's an exception to the msxml2 rule, I am surprised it's not
>> mentioned in
>> those places where PIE limitations _are_ discussed)? Or can anyone help
>> me
>> in finding ways to get this to work? It might just be that I've got the
>> blah:xmlns
>> declarations wrong for PIE, for instance.
>>
>> Anyway, I'm pretty sure that I can live without it by trundling through
>> the
>> DOM and doing text fixups as appropriate, but if I could build it into
>> the
>> stylesheet directly, it would be many times less effort and much
>> cleverer.
>>
>> many thanks for any pointers - if anyone wants to start a pocketIE
>> survivors
>> group, I'm in...
>>
>>
>> ed
>>
>>
>>
>
>
 
G

Guest

Guest
Archived from groups: microsoft.public.pocketpc,microsoft.public.pocketpc.developer (More info?)

I hate to follow up my own posts, but here's the answer.

For any like me who are trying to do anything interesting
with PIE (or who nostalgically yearn for the non-standard
elements of msxml2), it might be of interest:

xsl:script defines a javascript block, just as in an html
file (i.e. you wrap/hide code using <!-- //--> rather than
<![CDATA[...]]>)

xsl:eval allows you to call the functions you define (or
any arbitrary inline code you fancy), with "this" set to
the current node. you can use xpath-style selects on
that to get the nodes and attributes you require

e.g. this stylesheet renders the accompanying xml, with
a javascript hook to put company names in uppercase:

<xsl:stylesheet xmlns:xsl="uri:xsl">
<xsl:script language="JavaScript">
<!--
function uppercase(node) {
return(node.text.toUpperCase());
}
//-->
</xsl:script>
<xsl:template match="/">
<H3>Company Details </H3>
<TABLE>
<xsl:for-each select="Companies/Companies">
<TR>
<TD>
<xsl:eval>uppercase(this.selectSingleNode("Company_Name"))</xsl:eval>
</TD>
<TD>
<A>
<xsl:attribute name="HREF">details.html?id=<xsl:value-of
select="ID"/></xsl:attribute>more</A>
</TD>
</TR>
</xsl:for-each>
</TABLE>
</xsl:template>
</xsl:stylesheet>





<XML ID="companies">
<Companies>
<Companies>
<ID>3980</ID>
<Company_Name>Occidental Software</Company_Name>
</Companies>
<Companies>
<ID>4137</ID>
<Company_Name>Essential Software </Company_Name>
</Companies>
</Companies>
</XML>
 
G

Guest

Guest
Archived from groups: microsoft.public.pocketpc (More info?)

On Sat, 19 Feb 2005 10:15:09 -0000, "Ed Carter" <ed@springcorp.co.uk>
wrote:


> embedded script in msxml2 might or might not have been implemented
>using <xsl:script> or <msxml:script>, I've tried both.
>
>Now, the style sheet DOES parse ok with <[ms]xsl:script> tags in it,
>so there is some knowledge of it in the xslt implementation in PIE,
>but I just bump up against "unknown method" errors when I try
>to use it.

How about if you import or link to a .js file, rather than inlining
the script in <!CDATA>, does that work ? I guess cause if < and >
characters in the script it's not possible to pull it out of CDATA,
right ?

I seem to remember the binding order of msxml:script to the actual
script is important, and the browser has no idea that there's embedded
script in the stylesheet (although this works on the desktop browser).

Cheers - Neil
 
G

Guest

Guest
Archived from groups: microsoft.public.pocketpc (More info?)

Nice work ;-)

Now - what happens when you're outside the CDATA section and you need
to use if (a < b) {bla} in your javascript block, does it barf ? ;-))

Cheers - Neil

On Sat, 19 Feb 2005 12:18:10 -0000, "Ed Carter" <ed@springcorp.co.uk>
wrote:

>I hate to follow up my own posts, but here's the answer.
>
>For any like me who are trying to do anything interesting
>with PIE (or who nostalgically yearn for the non-standard
>elements of msxml2), it might be of interest:
>
>xsl:script defines a javascript block, just as in an html
>file (i.e. you wrap/hide code using <!-- //--> rather than
><![CDATA[...]]>)
>
>xsl:eval allows you to call the functions you define (or
>any arbitrary inline code you fancy), with "this" set to
>the current node. you can use xpath-style selects on
>that to get the nodes and attributes you require
>
>e.g. this stylesheet renders the accompanying xml, with
>a javascript hook to put company names in uppercase:
>
><xsl:stylesheet xmlns:xsl="uri:xsl">
><xsl:script language="JavaScript">
><!--
> function uppercase(node) {
> return(node.text.toUpperCase());
> }
>//-->
></xsl:script>
> <xsl:template match="/">
> <H3>Company Details </H3>
> <TABLE>
> <xsl:for-each select="Companies/Companies">
> <TR>
> <TD>
> <xsl:eval>uppercase(this.selectSingleNode("Company_Name"))</xsl:eval>
> </TD>
> <TD>
> <A>
> <xsl:attribute name="HREF">details.html?id=<xsl:value-of
>select="ID"/></xsl:attribute>more</A>
> </TD>
> </TR>
> </xsl:for-each>
> </TABLE>
> </xsl:template>
></xsl:stylesheet>
>
>
>
>
>
><XML ID="companies">
><Companies>
> <Companies>
> <ID>3980</ID>
> <Company_Name>Occidental Software</Company_Name>
> </Companies>
> <Companies>
> <ID>4137</ID>
> <Company_Name>Essential Software </Company_Name>
> </Companies>
></Companies>
></XML>
>
 
G

Guest

Guest
Archived from groups: microsoft.public.pocketpc (More info?)

> Now - what happens when you're outside the CDATA section and you need
> to use if (a < b) {bla} in your javascript block, does it barf ? ;-))

of course it does, it's msxml2!

within <xsl:script, CDATA isn't understood so - if you feel you need to -
you
should wrap script with <!-- -->. whether or not you include this commenting
construct inside xsl:script, both of these will cause parse errors:

if(spoiler-->5) { ...
if(spoiler < 100) { ...

ditto for xsl:eval elements (basically you can't use the < operator !?)

unfortunately, the script within the stylesheet also seems to be sandboxed
or
otherwise restricted to the stylesheet so you can't refer to external
javascript,
or get to the document/window objects. that and the xml dom is read-only,
which is also a shame... you could have done some really nice/evil things
(like
progress bars during long transforms) with that :)

stop press! I've just got external javascript libraries working by importing
them using the XMLHTTP object and inserting them into the stylesheet
DOM onLoad. ie javascript-based support for this (unsupported) syntax:
<xsl:script language="JavaScript" src="outside.xml" />
....neat!


I think it's time I stopped obsessing about this now, though, there's enough
there to do what I need to do.



ed
 
G

Guest

Guest
Archived from groups: microsoft.public.pocketpc (More info?)

On Sat, 19 Feb 2005 17:02:27 -0000, "Ed Carter" <ed@springcorp.co.uk>
wrote:

>> Now - what happens when you're outside the CDATA section and you need
>> to use if (a < b) {bla} in your javascript block, does it barf ? ;-))
>
>of course it does, it's msxml2!

>stop press! I've just got external javascript libraries working by importing
>them using the XMLHTTP object and inserting them into the stylesheet
>DOM onLoad. ie javascript-based support for this (unsupported) syntax:
> <xsl:script language="JavaScript" src="outside.xml" />
>...neat!

Good work (although I meant <xsl:import> if it was supported by MSXML2

>I think it's time I stopped obsessing about this now, though, there's enough
>there to do what I need to do.

Yep time for the pub for both of us I think ;-)

Cheers - Neil