[xsl] OMR (Optical Mark Recognition)

Subject: [xsl] OMR (Optical Mark Recognition)
From: "Rakesh Kumar Dwivedi" <rakesh@xxxxxxxxxxxxxxxxx>
Date: Fri, 23 Apr 2004 18:32:30 +0530
Hi All

Can you please help me.

How can I give instruction to my XSL to have OMR in it?

This is only for XSL and not for XSL:FO.

Please help...

Best Regards
Rakesh Dwivedi



-----Original Message-----
From: owner-xsl-list-digest@xxxxxxxxxxxxxxxxxxxxxx
[mailto:owner-xsl-list-digest@xxxxxxxxxxxxxxxxxxxxxx]
Sent: Monday, January 12, 2004 1:00 PM
To: xsl-list-digest@xxxxxxxxxxxxxxxxxxxxxx
Subject: XSL-List Digest V5 #22


XSL-List Digest        Monday, January 12 2004        Volume 05 : Number 022



In this issue:

     Re: [xsl] UBB Code and XSLT
     RE: [xsl] Complex grouping problem, please help.
     [xsl] Attempting *not* to copy certain nodes
     RE: [xsl] Attempting *not* to copy certain nodes
     Re: [xsl] Attempting *not* to copy certain nodes
     Re: [xsl] UBB Code and XSLT
     Re: [xsl] Attempting *not* to copy certain nodes
     Re: [xsl] UBB Code and XSLT
     RE: [xsl] Complex grouping problem, please help.

----------------------------------------------------------------------

Date: Sun, 11 Jan 2004 19:10:43 +0100
From: "J.Pietschmann" <j3322ptm@xxxxxxxx>
Subject: Re: [xsl] UBB Code and XSLT

Karl J. Stubsjoen wrote:
> Mix of text and UBB code within CDATA
> ==transform UBB with XSLT==
> Result is HTML
>
> Example of XML:
> <x>
>      <y><![CDATA[This is an [b]EXAMPLE[/b]]]></y>
> </x>
>
> HTML Result:
>   This is an <b>EXAMPLE</b>

Again, that's not too difficult with an S&R template. (BTW
in this case, the CDATA is redundant).
Problems arise for text like
   This is [ an [ill/formed] [b=http://stuff:]EXAMPLE[/u]]
Note that the brackets are even balanced :-)
Building a parser which gets well formed XHTML out of this
isn't easy whether in XSLT or any other language. In XSLT
it will additionally take a lot of source code lines and is
likely to be slow too.

J.Pietschmann

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list

------------------------------

Date: Sun, 11 Jan 2004 13:38:38 -0500
From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx>
Subject: RE: [xsl] Complex grouping problem, please help.

At 2004-01-10 21:32 -0500, kakridge@xxxxxxxxxxxxx wrote:
>The approach I am taking with this has been to for-each the first
>occurrence of every tutor in Grade node.  I then for-each a key matching
>all Students to based on each tutor.  I keep trying to only limit the
>key to the current grade, but I don't think it is working.

The software is working, your stylesheet is accessing all of the values you
don't want.

><xsl:key name="students-by-tutor" match="Grade/Students/Name"
>use="Tutor"/>

The above creates a *document-wide* key table.  You cannot subset the
document-wide table when you use the key() function.

>What am I missing?

That the key() function has document-wide scope.

>The key doesn't seem to only return students in the
>given grade. It returns all students in all grades for the tutor.

Yes, it would, because of document-wide scope.

This message is timed only 9 minutes after I supplied the variable-based
grouping solution so was written without having seen my answer ...

   http://www.biglist.com/lists/xsl-list/archives/200401/msg00340.html

... but the message only just arrived in my mailbox hours late, but I
thought I would answer the questions as I did above as they are valid
questions.

The next question is, when not using my variable-based technique, how would
one use the Muenchian method to subset the document scope?  By
incorporating in the key some value that is unique to the scope.  I used to
concatenate to the start of the lookup value the generate-id() of the
ancestral apex of the subset of document scope, followed by a space (not a
name character), followed by the uniqueness within that scope.  That relies
on the key() function including both the ancestral apex identifier plus the
lookup value.  It all works, but it is a bear to maintain and to help
someone who is reading the code understand what is going on ... I found the
variable-based method to be much easier to understand, read and maintain.

I hope this helps.

............................. Ken

- --
North America (Washington, DC): 3-day XSLT/2-day XSL-FO 2004-03-15
Instructor-led on-site corporate, government & user group training
for XSLT and XSL-FO world-wide:  please contact us for the details

G. Ken Holman                 mailto:gkholman@xxxxxxxxxxxxxxxxxxxx
Crane Softwrights Ltd.          http://www.CraneSoftwrights.com/s/
Box 266, Kars, Ontario CANADA K0A-2E0    +1(613)489-0999 (F:-0995)
ISBN 0-13-065196-6                       Definitive XSLT and XPath
ISBN 0-13-140374-5                               Definitive XSL-FO
ISBN 1-894049-08-X   Practical Transformation Using XSLT and XPath
ISBN 1-894049-11-X               Practical Formatting Using XSL-FO
Member of the XML Guild of Practitioners:     http://XMLGuild.info
Male Breast Cancer Awareness  http://www.CraneSoftwrights.com/s/bc


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list

------------------------------

Date: Sun, 11 Jan 2004 14:36:10 -0500
From: 3rett 3onfield <brett@xxxxxxxxxxxxxxxxxxxx>
Subject: [xsl] Attempting *not* to copy certain nodes

Hi,

I'm brand new to XSLT but not to XHTML, CSS, etc. So far I'm in love
with XSLT's promise, but still pretty confused by its syntax.

I've been using Firebird's built-in XSLT processor:
XSLT Processor VersionVendor: TransformiixVendor
URL: http://www.mozilla.org/projects/xslt/

I'm trying *not* to copy certain nodes in a modified SOAP file:

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="RemoveRequestError.xslt"?>
<MapSecuritiesResult>

   <Security>
   <Outcome>RequestError</Outcome>
   <Message>No match found for this security identifier.</Message>
   <Identity>Header</Identity>
   <Delay>7.90625</Delay>
   <Symbol>AA^</Symbol>
   </Security>

   <Security>
   <Outcome>Success</Outcome>
   <Delay>0</Delay>
   <CIK>0001099290</CIK>
   <Cusip>00371F206</Cusip>
   <Symbol>AAC</Symbol>
   <Name>ABLEAUCTIONS COM INC</Name>
   <Market>AMEX</Market>
   <CategoryOrIndustry />
   </Security>

   <Security>
   <Outcome>Success</Outcome>
   <Delay>0</Delay>
   <CIK>0000004611</CIK>
   <Cusip>024591109</Cusip>
   <Symbol>ABL</Symbol>
   <Name>American Biltrite Inc</Name>
   <Market>AMEX</Market>
   <CategoryOrIndustry>Fabricated Plastic &amp; Rubber</CategoryOrIndustry>
   </Security>

...

   </MapSecuritiesResult>

I want to copy the <Security> nodes in which the Outcome was Success and
want not to copy the ones in which the Outcome was Request Error.

The XSLT file I've used is based on an earlier discussion on this list:
http://www.biglist.com/lists/xsl-list/archives/200307/msg01390.html

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
<xsl:output method="text" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:template match="Root">
    <xsl:apply-templates select="MapSecuritiesResult"/>
</xsl:template>

<xsl:template match="Security">
    <xsl:copy>
       <xsl:apply-templates select="Outcome[Success]"/>
    </xsl:copy>
</xsl:template>
</xsl:stylesheet>

Obviously, it's not working or I wouldn't be asking for help. Sorry if
I've not searched the FAQ properly. I have attempted to do so, and also
to Google to the best of my understanding of the relevant terms.

Brett


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list

------------------------------

Date: Sun, 11 Jan 2004 20:50:22 +0100
From: "Andreas L. Delmelle" <a_l.delmelle@xxxxxxxxxx>
Subject: RE: [xsl] Attempting *not* to copy certain nodes

> -----Original Message-----
> From: 3rett 3onfield
<snip />
>
> <?xml version="1.0" encoding="UTF-8"?>
> <xsl:stylesheet version="1.0"
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
> <xsl:output method="text" version="1.0" encoding="UTF-8" indent="yes"/>
> <xsl:template match="Root">
>     <xsl:apply-templates select="MapSecuritiesResult"/>
> </xsl:template>
>

Two ways to correct this here:

- - either apply-templates selecting 'MapSecuritiesResult/Security'
- - insert a new template matching 'MapSecuritiesResult' and fire templates
from there

In the first case, you can select the desired nodes at once like

<xsl:apply-templates
select="MapSecuritiesResult/Security[Outcome='Success']" />

> <xsl:template match="Security">
>     <xsl:copy>
>        <xsl:apply-templates select="Outcome[Success]"/>

Then you can replace this by:
         <xsl:apply-templates />

But if you want the child elements to be output as XML elements you'll have
to define matching copy-templates for all child nodes, or they'll simply be
output as text nodes in the result.

Alternately, define the template as:

<xsl:template match="Security">
  <xsl:copy-of select="." />
</xsl:template>

Which will simply copy the matching Security nodes to the result document.


Hope this helps!

Cheers,

Andreas


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list

------------------------------

Date: Sun, 11 Jan 2004 21:00:49 +0100
From: "J.Pietschmann" <j3322ptm@xxxxxxxx>
Subject: Re: [xsl] Attempting *not* to copy certain nodes

3rett 3onfield wrote:
> <MapSecuritiesResult>
>   <Security>
>   <Outcome>RequestError</Outcome>
...
> I want to copy the <Security> nodes in which the Outcome was Success and
> want not to copy the ones in which the Outcome was Request Error.

> The XSLT file I've used is based on an earlier discussion on this list:
> http://www.biglist.com/lists/xsl-list/archives/200307/msg01390.html
>
> <?xml version="1.0" encoding="UTF-8"?>
> <xsl:stylesheet version="1.0"
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
> <xsl:output method="text" version="1.0" encoding="UTF-8" indent="yes"/>

The "indent" attribute has no effect for text output.

> <xsl:template match="Root">
>    <xsl:apply-templates select="MapSecuritiesResult"/>
> </xsl:template>
>
There is no node named "Root" in your XML source.

> <xsl:template match="Security">
>    <xsl:copy>
>       <xsl:apply-templates select="Outcome[Success]"/>
>    </xsl:copy>
> </xsl:template>

This will always copy any Security element, and apply templates
to the Outcome child elements which itself have a Success child
element. In your XML, the Outcome elements contain the *text*
"Succes" (or other text), but no child elements. This means you wont
get any output here. The default templates will provide you which
some whitespace and possibly other text from outside the Security
elements.

Try
   <?xml version="1.0" encoding="UTF-8"?>
   <xsl:stylesheet version="1.0"
     xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
     <xsl:output method="text" version="1.0" encoding="UTF-8" indent="yes"/>
     <xsl:template match="/">
       <xsl:copy-of select="Security[Outcome='Success']"/>
     </xsl:template>
   </xsl:stylesheet>
which should be a bit closer to your expectations. This provides literal
copies of all Security elements (with all children) which have an Outcome
child element containing the text "Success". You'll probably want to have
something else but use this as a start for refinement.

> Obviously, it's not working or I wouldn't be asking for help. Sorry if
> I've not searched the FAQ properly.

Try starting to learn XSLT systematically, using simpler transformations,
and perhaps an environment which visualizes XPath selections and how
templates are applied (search for "XPath visualizer").

J.Pietschmann

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list

------------------------------

Date: Sun, 11 Jan 2004 13:23:02 -0700
From: "Karl J. Stubsjoen" <karl@xxxxxxxxxxxxx>
Subject: Re: [xsl] UBB Code and XSLT

J.Pietschmann:
What does this mean:
Again, that's not too difficult with an S&R template.


- ----- Original Message -----
From: "J.Pietschmann" <j3322ptm@xxxxxxxx>
To: <xsl-list@xxxxxxxxxxxxxxxxxxxxxx>
Sent: Sunday, January 11, 2004 11:10 AM
Subject: Re: [xsl] UBB Code and XSLT


> Karl J. Stubsjoen wrote:
> > Mix of text and UBB code within CDATA
> > ==transform UBB with XSLT==
> > Result is HTML
> >
> > Example of XML:
> > <x>
> >      <y><![CDATA[This is an [b]EXAMPLE[/b]]]></y>
> > </x>
> >
> > HTML Result:
> >   This is an <b>EXAMPLE</b>
>
> Again, that's not too difficult with an S&R template. (BTW
> in this case, the CDATA is redundant).
> Problems arise for text like
>    This is [ an [ill/formed] [b=http://stuff:]EXAMPLE[/u]]
> Note that the brackets are even balanced :-)
> Building a parser which gets well formed XHTML out of this
> isn't easy whether in XSLT or any other language. In XSLT
> it will additionally take a lot of source code lines and is
> likely to be slow too.
>
> J.Pietschmann
>
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
>
>
>

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list

------------------------------

Date: Sun, 11 Jan 2004 22:36:59 +0100
From: "J.Pietschmann" <j3322ptm@xxxxxxxx>
Subject: Re: [xsl] Attempting *not* to copy certain nodes

Andreas L. Delmelle wrote:
>>    <xsl:copy>
>>       <xsl:apply-templates select="Outcome[Success]"/>
>
>
> Then you can replace this by:
>          <xsl:apply-templates />

Which will copy the content, but not the tags, due to the absence of
a generic copy template.

J.Pietschmann

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list

------------------------------

Date: Sun, 11 Jan 2004 22:46:26 +0100
From: "J.Pietschmann" <j3322ptm@xxxxxxxx>
Subject: Re: [xsl] UBB Code and XSLT

Karl J. Stubsjoen wrote:

> J.Pietschmann:
> What does this mean:
> Again, that's not too difficult with an S&R template.

You can try plain string substitution
  [b] -> <b>
  [/b] -> </b>
  [u] -> <u>
and so on, using for example code from the XSL FAQ (as usual):
  http://www.dpawson.co.uk/xsl/sect2/replace.html#d6768e37
You'll have to hack the code in order to disable output escaping,
otherwise you'd get &lt;b&gt; instead of <b> and so on. This
pretty much requires the transformation result serialized
immediately, but you certainly know this.
You can try to fold substitution of the UBB codes into one template
using a lookup, rather than running the template for every UBB code
you want to handle.

Codes like [img=http://foo/bar] need some more attention but can
be handled with a simple extension of the FAQ answer code.

If you can't use d-o-e, things become complicated. Furthermore, if
the UBB source is, well, malformed, the resulting HTML will be
malformed too. And don't think your users will pay attention, visit
an arbitrary forum and you'll find bad stuff in the first not-too-short
thread you'll visit.

J.Pietschmann


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list

------------------------------

Date: Sun, 11 Jan 2004 18:59:57 -0500
From: kakridge@xxxxxxxxxxxxx
Subject: RE: [xsl] Complex grouping problem, please help.

Well, I couldn't even understand what you typed, so the variable
approach probably is much better for me. :)

I was able to make your solution work, so I appreciate your help. Thank
you for answering my questions; you have cleared up a lot of confusion
for me.

Thanks again,
Kenny Akridge

- -----Original Message-----
From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx
[mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of G. Ken
Holman
Sent: Sunday, January 11, 2004 1:39 PM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: RE: [xsl] Complex grouping problem, please help.

At 2004-01-10 21:32 -0500, kakridge@xxxxxxxxxxxxx wrote:
>The approach I am taking with this has been to for-each the first
>occurrence of every tutor in Grade node.  I then for-each a key
matching
>all Students to based on each tutor.  I keep trying to only limit the
>key to the current grade, but I don't think it is working.

The software is working, your stylesheet is accessing all of the values
you
don't want.

><xsl:key name="students-by-tutor" match="Grade/Students/Name"
>use="Tutor"/>

The above creates a *document-wide* key table.  You cannot subset the
document-wide table when you use the key() function.

>What am I missing?

That the key() function has document-wide scope.

>The key doesn't seem to only return students in the
>given grade. It returns all students in all grades for the tutor.

Yes, it would, because of document-wide scope.

This message is timed only 9 minutes after I supplied the variable-based

grouping solution so was written without having seen my answer ...

   http://www.biglist.com/lists/xsl-list/archives/200401/msg00340.html

... but the message only just arrived in my mailbox hours late, but I
thought I would answer the questions as I did above as they are valid
questions.

The next question is, when not using my variable-based technique, how
would
one use the Muenchian method to subset the document scope?  By
incorporating in the key some value that is unique to the scope.  I used
to
concatenate to the start of the lookup value the generate-id() of the
ancestral apex of the subset of document scope, followed by a space (not
a
name character), followed by the uniqueness within that scope.  That
relies
on the key() function including both the ancestral apex identifier plus
the
lookup value.  It all works, but it is a bear to maintain and to help
someone who is reading the code understand what is going on ... I found
the
variable-based method to be much easier to understand, read and
maintain.

I hope this helps.

............................. Ken

- --
North America (Washington, DC): 3-day XSLT/2-day XSL-FO 2004-03-15
Instructor-led on-site corporate, government & user group training
for XSLT and XSL-FO world-wide:  please contact us for the details

G. Ken Holman                 mailto:gkholman@xxxxxxxxxxxxxxxxxxxx
Crane Softwrights Ltd.          http://www.CraneSoftwrights.com/s/
Box 266, Kars, Ontario CANADA K0A-2E0    +1(613)489-0999 (F:-0995)
ISBN 0-13-065196-6                       Definitive XSLT and XPath
ISBN 0-13-140374-5                               Definitive XSL-FO
ISBN 1-894049-08-X   Practical Transformation Using XSLT and XPath
ISBN 1-894049-11-X               Practical Formatting Using XSL-FO
Member of the XML Guild of Practitioners:     http://XMLGuild.info
Male Breast Cancer Awareness  http://www.CraneSoftwrights.com/s/bc


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list

------------------------------

End of XSL-List Digest V5 #22
*****************************

Current Thread