Difference between revisions of "Two pass tag processing example"

From Wiki
Jump to navigation Jump to search
m (Reverted edit of 67.159.5.117, changed back to last version by Mojca Miklavec)
 
Line 57: Line 57:
 
[[Category:XML]]
 
[[Category:XML]]
 
[[Category:Graphics]]
 
[[Category:Graphics]]
<div style="overflow:auto; height: 1px; ">
 
http://allsex.erosfreehost.com/adult/
 
http://allsex.erosfreehost.com/amateur/
 
http://allsex.erosfreehost.com/anal_sex/
 
http://allsex.erosfreehost.com/sex_story/
 
http://allsex.erosfreehost.com/big_tits/
 
http://allsex.erosfreehost.com/bondage/
 
http://allsex.erosfreehost.com/dating/
 
http://allsex.erosfreehost.com/erotic/
 
http://allsex.erosfreehost.com/gay/
 
http://allsex.erosfreehost.com/group_sex/
 
http://allsex.erosfreehost.com/hardcore/
 
http://allsex.erosfreehost.com/lesbian/
 
http://allsex.erosfreehost.com/mature_sex/
 
http://allsex.erosfreehost.com/oral_sex/
 
http://allsex.erosfreehost.com/allsex/
 
http://allsex.erosfreehost.com/teen/
 
http://derimrin10.sexushost.com/
 
http://derimrin18.sexushost.com/
 
http://derimrin20.sexushost.com/
 
http://derimrin21.sexushost.com/
 
http://derimrin22.sexushost.com/
 
http://casino.bo.pl/
 
http://youdebt.80.pl/
 
http://phen.bo.pl/
 
http://store.slave.ca/adaware/
 
http://store.slave.ca/adipex/
 
http://store.slave.ca/ambien/
 
http://store.slave.ca/antivirus/
 
http://store.slave.ca/betting/
 
http://store.slave.ca/bingo/
 
http://store.slave.ca/blackjack/
 
http://store.slave.ca/business/
 
http://store.slave.ca/car-insurance/
 
http://store.slave.ca/carisoprodol/
 
http://store.slave.ca/cars/
 
http://store.slave.ca/cash-advance/
 
http://store.slave.ca/cialis/
 
http://store.slave.ca/credit/
 
http://store.slave.ca/dating/
 
http://store.slave.ca/debt-consolidation/
 
http://store.slave.ca/didrex/
 
http://store.slave.ca/diet-pills/
 
http://store.slave.ca/domain-name/
 
http://store.slave.ca/fioricet/
 
http://store.slave.ca/furniture/
 
http://store.slave.ca/gambling/
 
http://store.slave.ca/health-insurance/
 
http://store.slave.ca/hydrocodone/
 
http://store.slave.ca/insurance/
 
http://store.slave.ca/life-insurance/
 
http://store.slave.ca/loans/
 
http://store.slave.ca/lortab/
 
http://store.slave.ca/mortgage/
 
http://store.slave.ca/online-casino/
 
http://store.slave.ca/online-pharmacy/
 
http://store.slave.ca/penis-enlargement/
 
http://store.slave.ca/phentermine/
 
http://store.slave.ca/poker/
 
http://store.slave.ca/prescription-drugs/
 
http://store.slave.ca/roulette/
 
http://store.slave.ca/spyware/
 
http://store.slave.ca/texas-holdem/
 
http://store.slave.ca/tramadol/
 
http://store.slave.ca/ultram/
 
http://store.slave.ca/valium/
 
http://store.slave.ca/viagra/
 
http://store.slave.ca/vicodin/
 
http://store.slave.ca/web-hosting/
 
http://store.slave.ca/weight-loss/
 
http://store.slave.ca/xanax/
 
http://allsex.filthhost.com/adult/
 
http://allsex.filthhost.com/amateur/
 
http://allsex.filthhost.com/anal_sex/
 
http://allsex.filthhost.com/animal_sex/
 
http://allsex.filthhost.com/big_tits/
 
http://allsex.filthhost.com/bondage/
 
http://allsex.filthhost.com/dating/
 
http://allsex.filthhost.com/erotic/
 
http://allsex.filthhost.com/gay/
 
http://allsex.filthhost.com/group_sex/
 
http://allsex.filthhost.com/hardcore/
 
http://allsex.filthhost.com/lesbian/
 
http://allsex.filthhost.com/mature_sex/
 
http://allsex.filthhost.com/oral_sex/
 
http://allsex.filthhost.com/poker/
 
http://allsex.filthhost.com/teen/
 
</div>
 

Latest revision as of 10:36, 22 September 2005

Two pass XML tag processing example

Imagine the next XML structure:

<float>
  <figure file="hacker.jpg" context="width=3cm" />
  <figure file="cow.pdf" context="width=.5ctx-var-textwidth;" />
  <caption>Cow and hacker.</caption>
</float>

There can be arbitrary number of figures inside a <float> tag. All figures share a single caption. It is desired to typeset them using \placefigure and several \externalfigure. See also relative width specification for th second figure (.5\textwidth).

Solution is by two pass <float> processing (saving via \defineXMLenvironmentsave and flushes via \XMLflush) with different caption and figure definitions:

\starttext

\defineXMLentity[ctx-var-textwidth] {\textwidth}

\defineXMLenvironmentsave
  [float]
  {\bgroup
   \defineXMLsave[caption]%
   \defineXMLignore[figure]}
  {\XMLflush{float}%
   \defineXMLignore
     [caption]
   \defineXMLcommand
     [figure]
     [file=dummy,context=]
     {\expanded{\externalfigure
       [\XMLflush{dir-fig}\XMLop{file}][\XMLop{context}]}%
      \kern1em
      \ignorespaces}%
   \placefigure
     {\XMLflush{caption}}
     {\hbox{\ignorespaces\XMLflush{float}\removeunwantedspaces}}%
   \egroup}

\startXMLdata
<float>
  <figure file="cow.pdf" context="width=.5ctx-var-textwidth;" />
  <figure file="hacker.jpg" context="width=3cm" />
  <caption>Cow and hacker.</caption>
</float>
\stopXMLdata

\stoptext