LISTSERV mailing list manager LISTSERV 16.0

Help for XML-L Archives


XML-L Archives

XML-L Archives


XML-L@LISTSERV.HEANET.IE


View:

Message:

[

First

|

Previous

|

Next

|

Last

]

By Topic:

[

First

|

Previous

|

Next

|

Last

]

By Author:

[

First

|

Previous

|

Next

|

Last

]

Font:

Proportional Font

LISTSERV Archives

LISTSERV Archives

XML-L Home

XML-L Home

XML-L  November 2010

XML-L November 2010

Subject:

Re: Somewhere between parsing and data binding?

From:

Peter Flynn <[log in to unmask]>

Reply-To:

General discussion of Extensible Markup Language <[log in to unmask]>

Date:

Thu, 25 Nov 2010 00:04:31 +0000

Content-Type:

text/plain

Parts/Attachments:

Parts/Attachments

text/plain (117 lines)

On 24/11/10 23:01, Peter Davis wrote:
> I hope you're at least enjoying this exchange, as I am.  I'd hate to be
> wasting your time.

It's on-topic anyway :-)

[...]
> Basically, the parser has to look at every character in the input XML
> data, to determine where "<" and ">" occur.  So in the process of doing
> that, it could also be identifying pre-determined strings, like element
> names.  Otherwise, whether it's SAX or DOM, all it's tell the calling
> application that there are elements.

I don't think that's correct. At least I really hope not.

> The application than has to scan
> the strings again to figure out what the element names are.  That the
> primary inefficiency that troubles me.

I would be very worried if it had to do this. AFAIK the result of a
parse is an InfoSet (PSVI or Grove) which contains the whole caboodle,
names and all. I think I should go check with someone who writes this
stuff internally, just to make sure.

> I'm not sure what you mean by "procedural" here.  This is pretty much
> the approach that Expat and other SAX parsers require you to take.  For
> DOM parsers, the code is similar, but it's in the context of traversing
> the tree.

I'm sorry, I didn't mean procedural at the level of the parser. I meant
at the level of handling the document (eg in XSLT).

[...]
> Yes, XSLT is looking good.  I've also found some example XSLT files for
> generating TeX/LaTeX, so that's a good head start.

I have acres of those if you need them. There's a big one downloadable
from my online LaTeX book (see production note at
http://latex.silmaril.ie/formattinginformation/intro.html#prodnote for
the link).

[...]
> Unfortunately, I can't pre-process the images in this application.  I
> don't know what or where they are until I process the XML.  I could
> process the XML twice, but that's ugly.  It would mean processing the
> XML to make a list of image URIs, then running through the list with
> some other process to get all the image info, and finally processing the
> XML again to generate the markup.

That's exactly what I would do: the script fragment I posted does that.
Passing over the document to grab the image file names is very fast: I
just tested lxgrep on a very complex 1Mb DocBook document and it took
under a second:

$ date;lxgrep -w pix '//graphic' thesis.xml >pix.xml 2>pix.err;date
Wed Nov 24 23:32:43 GMT 2010
Wed Nov 24 23:32:44 GMT 2010

Grabbing the info from the images is going to take about the same amount
of time no matter what way you do it. I wouldn't be afraid to preprocess
a document in order to get the data: it's a perfectly normal way to work
in a pipeline.

> Yes, so do I.  As I said, XSLT seems to be *almost* there, but I need to
> solve the image problem. 

I bit the bullet and finished the script. This is rough and ready, but
it reads the file above and gets the image data. There are a few Mb
sized EPS files which take up most of the 19 seconds: omitting them
brought it down to 8 secs. (Not all my @filerefs have the images/ path
so some of the script rationalises that, and needs to be omitted elsewhere.)

> $ date;echo "<images>";for f in `lxgrep '//graphic/@fileref' thesis.xml 2>/dev/null | awk -F\" '{print $2}' | grep -v '^$' | sed -e "s+images/++"`; do if [ -s images/$f.png ]; then F=$f.png; elif [ -s images/$f.pdf ]; then F=$f.pdf; else F=$f.eps; fi; identify images/$F; done | awk '{n=split($3,xy,"x");print "<image name=\"" $1 "\" type=\"" $2 "\" x=\"" xy[1] "\" y=\"" xy[2] "\" depth=\"" $5 "\" size=\"" $(NF-2) "\"/>"}';echo "</images>";date
> Wed Nov 24 23:57:20 GMT 2010
> <images>
> <image name="images/ptx104.eps" type="PS" x="828" y="1134" depth="16-bit" size="996KiB"/>
> <image name="images/vin155.eps" type="PS" x="1069" y="967" depth="16-bit" size="767KiB"/>
> <image name="images/legal-mono.eps" type="PS" x="360" y="504" depth="16-bit" size="34.8KiB"/>
> <image name="images/vesalius-text.png" type="PNG" x="1311" y="2010" depth="8-bit" size="325KiB"/>
> <image name="images/floatingpara.pdf" type="PDF" x="595" y="842" depth="16-bit" size="61.7KiB"/>
> <image name="images/floatingpara-edit.png" type="PNG" x="674" y="479" depth="8-bit" size="948KiB"/>
> <image name="images/tree.png" type="PNG" x="1009" y="689" depth="8-bit" size="36KiB"/>
> <image name="images/distrib.png" type="PNG" x="396" y="357" depth="8-bit" size="23.2KiB"/>
> <image name="images/exp-q2-crop.pdf" type="PDF" x="290" y="288" depth="16-bit" size="10.5KiB"/>
> <image name="images/editors-crop.pdf" type="PDF" x="765" y="493" depth="16-bit" size="46.3KiB"/>
> <image name="images/survey-oocalc-encode.png" type="PNG" x="1023" y="689" depth="8-bit" size="73.3KiB"/>
> <image name="images/framemap-crop.pdf" type="PDF" x="606" y="237" depth="16-bit" size="17.7KiB"/>
> <image name="images/model-dynamics-crop.pdf" type="PDF" x="818" y="514" depth="16-bit" size="51.8KiB"/>
> <image name="images/example-screen-crop.pdf" type="PDF" x="598" y="451" depth="16-bit" size="33.1KiB"/>
> <image name="images/criticalturns-edit.png" type="PNG" x="1024" y="690" depth="8-bit" size="195KiB"/>
> <image name="images/criticalturns-typeset.png" type="PNG" x="642" y="687" depth="8-bit" size="102KiB"/>
> <image name="images/modal-ws-crop.pdf" type="PDF" x="169" y="234" depth="16-bit" size="5.09KiB"/>
> <image name="images/tabex-crop.pdf" type="PDF" x="228" y="98" depth="16-bit" size="2.84KiB"/>
> <image name="images/modal-tab-crop.pdf" type="PDF" x="169" y="238" depth="16-bit" size="5.18KiB"/>
> <image name="images/bs-del-example-before.png" type="PNG" x="601" y="171" depth="8-bit" size="30.1KiB"/>
> <image name="images/bs-del-example-after.png" type="PNG" x="601" y="138" depth="8-bit" size="28.7KiB"/>
> <image name="images/modal-sp-crop.pdf" type="PDF" x="169" y="198" depth="16-bit" size="4.32KiB"/>
> <image name="images/lyxtoolbar.png" type="PNG" x="874" y="91" depth="8-bit" size="26.9KiB"/>
> <image name="images/ibutton-crop.pdf" type="PDF" x="139" y="149" depth="16-bit" size="2.68KiB"/>
> <image name="images/fontdropdown-crop.pdf" type="PDF" x="253" y="164" depth="16-bit" size="5.19KiB"/>
> <image name="images/desclistbutton-crop.pdf" type="PDF" x="390" y="28" depth="16-bit" size="1.4KiB"/>
> <image name="images/cursor1-crop.pdf" type="PDF" x="352" y="138" depth="16-bit" size="5.99KiB"/>
> <image name="images/cursor2-crop.pdf" type="PDF" x="352" y="138" depth="16-bit" size="5.99KiB"/>
> <image name="images/cursor3-crop.pdf" type="PDF" x="352" y="138" depth="16-bit" size="5.99KiB"/>
> <image name="images/cursor4-crop.pdf" type="PDF" x="352" y="138" depth="16-bit" size="5.99KiB"/>
> <image name="images/cursor5-crop.pdf" type="PDF" x="313" y="144" depth="16-bit" size="5.69KiB"/>
> <image name="images/cursor6-crop.pdf" type="PDF" x="313" y="147" depth="16-bit" size="5.8KiB"/>
> <image name="images/cursor7-crop.pdf" type="PDF" x="312" y="144" depth="16-bit" size="5.55KiB"/>
> <image name="images/cursor8-crop.pdf" type="PDF" x="313" y="243" depth="16-bit" size="9.55KiB"/>
> <image name="images/dndtoolbar.png" type="PNG" x="619" y="402" depth="8-bit" size="731KiB"/>
> <image name="images/expert-pilot1.pdf" type="PDF" x="595" y="842" depth="16-bit" size="61.7KiB"/>
> <image name="images/expert-pilot2.pdf" type="PDF" x="595" y="842" depth="16-bit" size="61.7KiB"/>
> </images>
> Wed Nov 24 23:57:39 GMT 2010
> $ 

///Peter

Top of Message | Previous Page | Permalink

Advanced Options


Options

Log In

Log In

Get Password

Get Password


Search Archives

Search Archives


Subscribe or Unsubscribe

Subscribe or Unsubscribe


Archives

January 2016
July 2014
April 2014
January 2014
July 2013
February 2013
September 2012
August 2012
October 2011
August 2011
June 2011
January 2011
November 2010
October 2010
July 2010
June 2010
March 2010
February 2010
January 2010
November 2009
September 2009
August 2009
July 2009
May 2009
March 2009
December 2008
October 2008
August 2008
May 2008
March 2008
February 2008
January 2008
December 2007
October 2007
August 2007
June 2007
March 2007
January 2007
December 2006
September 2006
July 2006
June 2006
April 2006
February 2006
January 2006
November 2005
September 2005
August 2005
July 2005
June 2005
May 2005
March 2005
January 2005
October 2004
August 2004
July 2004
June 2004
May 2004
March 2004
February 2004
January 2004
December 2003
November 2003
October 2003
September 2003
August 2003
July 2003
June 2003
May 2003
April 2003
March 2003
February 2003
January 2003
December 2002
November 2002
October 2002
September 2002
August 2002
July 2002
June 2002
May 2002
April 2002
March 2002
February 2002
January 2002
December 2001
November 2001
October 2001
September 2001
August 2001
July 2001
June 2001
May 2001
April 2001
March 2001
February 2001
January 2001
December 2000
November 2000
October 2000
September 2000
August 2000
July 2000
June 2000
May 2000
April 2000
March 2000
February 2000
January 2000
December 1999
November 1999
October 1999
September 1999
August 1999
July 1999
June 1999
May 1999
April 1999
March 1999
February 1999
January 1999
December 1998
November 1998
October 1998
September 1998
August 1998
July 1998
June 1998
May 1998
April 1998
March 1998
February 1998
December 1997
November 1997
October 1997

ATOM RSS1 RSS2



LISTSERV.HEANET.IE

CataList Email List Search Powered by the LISTSERV Email List Manager