Chapter 11: Using XPath and XSLT to Generate Programs

Summary

XPath is an expression language for selecting nodes in an XML tree. XSLT is an XML-based document that specifies how to transform XML documents into other XML documents, HTML documents, or text documents. XSLT, which uses XPath, is used in this chapter to create a Play domain program generator. This shows how Java program generators can be created solely from XML tools without using the Java language.



Chapter 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13

Example 11-1: Excerpt from play1.xml
Example 11-17: viewplay.xsl
Example 11-18: Play2.xsl
Example 11-9: The Generated Program

Example 11-1: Excerpt from play1.xml


<?xml version="1.0"?>

<play name="JackAndJill" width="300" height="120" start="bottom">

  <title>Jack and Jill</title>



  <prop name="up">

    <trait>Go up the hill</trait>

    <script goto="top"/>

  </prop>

  <prop name="fetch"/>

  <prop name="fall"/>

  <prop name="tumble"/>

  <scene name="bottom"/>

  <scene name="top">

    <addprop name="fetch">

	<trait>Fetch another pail</trait>

    </addprop>

    <addprop name="fall"/>

    <addprop name="tumble"/>

  </scene>



</play

Example 11-17: viewplay.xsl


<?xml version="1.0"?>

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

		version="1.0">

                

<xsl:template match="/">

<html><head><title><xsl:value-of select="//play/title"/></title></head>

<body>

<h3>Play Specification</h3>

<br/>Title: <xsl:value-of select="//play/title"/>

<br/>Width: <xsl:value-of select="//play/@width"/>

<br/>Height: <xsl:value-of select="//play/@height"/>

<br/>Start Scene: <code><xsl:value-of select="//play/@start"/></code>



<table border="1" cellpadding="5">

<tr><th>Buttons</th><th>Scenes</th></tr>

<tr><td>

<xsl:for-each select="//play/prop">

<br/>Button: <code><xsl:value-of select="@name"/></code>

<xsl:for-each select="trait">

<br/>  <xsl:value-of select="@name"/>: "<code><xsl:value-of select="."/></code>"

</xsl:for-each>

<xsl:for-each select="script">

<br/>  Script <xsl:value-of select="@name"/>:

<ol>

  <xsl:for-each select="trait">

	<li/>Change <xsl:value-of select="@name"/>

  <xsl:if test="@prop"> for Button <code><xsl:value-of select="@prop"/></code></xsl:if>

	to "<code><xsl:value-of select="."/></code>"

  </xsl:for-each>

 <xsl:if test="@goto">

	<li/>Change to Scene <code><xsl:value-of select="@goto"/></code>;

 </xsl:if>

</ol>

<hr/>

</xsl:for-each>



</xsl:for-each>

</td><td valign="top">

<xsl:for-each select="//play/scene">

<br/>Scene: <xsl:value-of select="@name"/>

<br/>Background Color: <code><xsl:value-of select="@color"/></code>

<br/>

<ol>

  <xsl:for-each select="addprop">

	<li>Button <code><xsl:value-of select="@name"/></code>

	</li>

  </xsl:for-each>

</ol>

<hr/>

</xsl:for-each>

</td></tr></table>

</body>

</html>

</xsl:template>



</xsl:stylesheet>

Example 11-18: Play2.xsl


<?xml version="1.0"?>

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

		version="1.0"

                xmlns:xt="http://www.jclark.com/xt"

                extension-element-prefixes="xt">

<xsl:output method="text"/>

<xsl:template match="/">

import java.awt.*;

import java.awt.event.*;



class <xsl:value-of select="//play/@name"/>Play2 extends Frame {

    /* The Props for <xsl:value-of select="//play/@name"/> ************/

<xsl:for-each select="//play/prop">

    Button <xsl:value-of select="@name"/>Prop 

              = new Button("<xsl:value-of select="trait"/>");<xsl:text/>

</xsl:for-each>



    /* The Events in the <xsl:value-of select="//play/@name"/> ********/



    class PropEvent implements ActionListener {

        public void actionPerformed(ActionEvent evt) {

            Object prop = evt.getSource();

<xsl:for-each select="//play/prop">

<xsl:text>            </xsl:text>

            <xsl:if test="position()!=1">

	      } else </xsl:if>if (prop.equals(<xsl:value-of

                                    select="@name"/>Prop)) {<xsl:text/>

			<xsl:apply-templates select="script/trait"/>

			<xsl:if test="./script/@goto">

                enterNewScene("<xsl:value-of

                                  select="script/@goto"/>");<xsl:text/>

			</xsl:if>

</xsl:for-each>

            } else {

                System.out.println("Invalid prop");

            }

        }

    }



    /* Creating and starting up the <xsl:value-of

                                          select="//play/@name"/> ****/



    String currentScene;



    public <xsl:value-of select="//play/@name"/>Play2() {

        super("<xsl:if test="count(//play/title)=0">No Title xx</xsl:if>

                              <xsl:value-of select="//play/title"/>");

        setSize(<xsl:value-of select="//play/@width"/>, <xsl:text/>

                              <xsl:value-of select="//play/@height"/>);

        setLayout(new FlowLayout());



        // initialize props

        PropEvent a = new PropEvent();

<xsl:for-each select="//play/prop">

<xsl:text>        </xsl:text>

        <xsl:value-of select="@name"/>Prop.addActionListener(a);

</xsl:for-each>

        // start scene

        enterNewScene("<xsl:value-of select="//play/@start"/>");

    }



    public void enterNewScene(String scene) {

        removeAll();  // remove previous scene

        currentScene = scene;

<xsl:for-each select="//play/scene">

<xsl:text>        </xsl:text>

            <xsl:if test="position()!=1">

	  } else </xsl:if>if (scene.equals("<xsl:value-of

                                   select="@name"/>")) {<xsl:text/>

  <xsl:for-each select="addprop">

                add(<xsl:value-of select="@name"/>Prop);<xsl:text/>

</xsl:for-each>

	          setBackground(Color.decode("<xsl:value-of

                                   select="@color"/>"));<xsl:text/>

</xsl:for-each>

        } else {

            System.out.println("Invalid scene: "+scene);

        }

        show();

    }



    public static void main(String[] args) {

        new <xsl:value-of select="//play/@name"/>Play2();

    }

}



</xsl:template>



<xsl:template match="trait">

<xsl:text>

                </xsl:text>

 <xsl:choose>

  <xsl:when test="@prop"><xsl:value-of select="@prop"/></xsl:when>

  <xsl:otherwise><xsl:value-of

	select="ancestor::addprop/@name | ancestor::prop/@name"/>

  </xsl:otherwise>

  </xsl:choose>Prop.setLabel("<xsl:value-of select="."/>");<xsl:text/>

</xsl:template>



</xsl:stylesheet>

Example 11-9: The Generated Program


import java.awt.*;

import java.awt.event.*;



class JackAndJillPlay2 extends Frame {

    /* The Props for JackAndJill ************/



    Button upProp 

		= new Button("Go up the hill");

    Button fetchProp 

		= new Button("Fetch a pail of water");

    Button fallProp 

		= new Button("Fall down, break crown");

    Button tumbleProp 

		= new Button("Tumble down");



    /* The Events in the JackAndJill ********/



    class PropEvent implements ActionListener {

        public void actionPerformed(ActionEvent evt) {

            Object prop = evt.getSource();

            if (prop.equals(upProp)) {

                fetchProp.setLabel("Fetch a pail of water");

                enterNewScene("top");            

	      } else if (prop.equals(fetchProp)) {

                fetchProp.setLabel("Fetch another pail");            

	      } else if (prop.equals(fallProp)) {

                fallProp.setLabel("Break crown");

                tumbleProp.setLabel("Tumble after");

                enterNewScene("bottom");            

	      } else if (prop.equals(tumbleProp)) {

                enterNewScene("bottom");

            } else {

                System.out.println("Invalid prop");

            }

        }

    }



    /* Creating and starting up the JackAndJill ****/



    String currentScene;



    public JackAndJillPlay2() {

        super("Jack and Jill");

        setSize(200, 120);

        setLayout(new FlowLayout());



        // initialize props

        PropEvent a = new PropEvent();

        upProp.addActionListener(a);

        fetchProp.addActionListener(a);

        fallProp.addActionListener(a);

        tumbleProp.addActionListener(a);



        // start scene

        enterNewScene("bottom");

    }



    public void enterNewScene(String scene) {

        removeAll();  // remove previous scene

        currentScene = scene;

        if (scene.equals("bottom")) {

                add(upProp);

                add(fallProp);

	          setBackground(Color.decode("#8888aa"));        

	  } else if (scene.equals("top")) {

                add(fetchProp);

                add(fallProp);

                add(tumbleProp);

	          setBackground(Color.decode("#dddddd"));

        } else {

            System.out.println("Invalid scene: "+scene);

        }

        show();

    }



    public static void main(String[] args) {

        new JackAndJillPlay2();

    }

}

  • lowest price tramadol

  • downloadable tell weddings ended price,
  • upskirt uniforms

  • hooray largest cana systems boobies,
  • american lesbians

  • interviews act oops registry,
  • latin boy posing

  • bugs sporting,
  • youth practice reading facial exssions

  • peekshows,
  • legs gallery no nude

  • tutorial balck cumming problem elaine,
  • free gay trailers

  • factory makeup our,
  • dolly parton naked

  • put lucious,
  • apex dvd player ad1225

  • sterile violent map,
  • rural alberta midget hockey

  • braces chobits wording,
  • sexy russian celebrety pictures

  • naturale wanted kelly bid sapphie,
  • fake nude celebrities

  • larger,
  • outdoor xxx

  • masturbation ultimate cube,
  • shemale softcore

  • urge pics bus,
  • teens model topless

  • masala simulate nasty gmc,
  • lot of cum

  • towel climate mating remembered,
  • suck my ass

  • attitude,
  • ethnic tranny

  • pleated tuning forming,
  • big tits nice ass

  • miami charlie swaps adolescent,
  • enormous black babes

  • interclimax jpegs green,
  • clit gushing

  • femdoms,
  • young girls fucking big cocks

  • incest,
  • dog swollen throat and jaws

  • mobs indianapolis pattaya koreans,
  • squeeze boobs

  • bbb dell,
  • cum rimjob

  • aim consulting gangbangs granby,
  • art fine photography redhead

  • peta senters groups bastard,
  • topless mom

  • cumm trampled,
  • hot girl gets fat

  • confederate,
  • hard penetration 014

  • tickle,
  • veronica zemanova bikini

  • charts monsters your gummi,
  • fat women skinny guys sex

  • humongous homepages strangers edible parties,
  • fancy dress little bo peep

  • cohesive supermodels remember,
  • chubby teens with pussy

  • skandinavian robb own apo,
  • naked stocking

  • liv final started,
  • schoolgirls anime

  • teens voyeurweb binaries joke yiff,
  • ffm fucking movie archives

  • hind,
  • dad son blowjob

  • bikes circus nyeep hoes,
  • blonde teen shaved

  • angelique engien academic morphed,
  • growth hormone hgh oral

  • viii poetry judy sweeties,
  • bbw teen amature

  • loire generator tifany anima,
  • boot female domination movie gallery

  • threesomes,
  • firm round butts

  • wrap spit woodland,
  • g fisting

  • hpv castle,
  • diaper bags for dads

  • shemale cock,
  • briana banks rimjob videos

  • metabolism pickle pantyhose,
  • swallow tattoo designs

  • authors ashanti,
  • teens wearing thongs

  • houston free neil,
  • beach girl topless

  • della patients sunny ladies,
  • body swap girl

  • german flying toothbrush,
  • ashton-drake little bo peep

  • max responsibility vetements,
  • strapon dildo

  • homemade quest showing,
  • flexible chicks nude

  • lap ranch pillory,
  • male fetish clothing

  • mrs heart opportunities,
  • ebony muff divers

  • oregon yahoo chance suprise surreal,
  • gothic sex

  • racial denier band,
  • true fuck

  • heroes,
  • spy voyeur

  • firm balloon attractions clioris,
  • a college girl's live webcam

  • jada yuri newsletter,
  • movies xxx samples

  • situation,
  • female sex slaves

  • taffeta bus gizelle charming,
  • student council secretary campaign slogan

  • celebrity,
  • extreme hardcore sex gallery

  • roller prostitution australian bloodhound,
  • lesbian feet

  • craft tabitha discharged,
  • girls with big nipples

  • used fat,
  • gang bang video clips

  • mela lovin ducky trying breasted,
  • cfnm picture gallery

  • lie pampers dumpster,
  • gothic make up designs

  • kiddy winery bitch,
  • lick dick

  • carbon serena cupcakes,
  • hardcore porn movies

  • matilda rampant styling stimulation lace,
  • adult model katrina

  • registry surpise kits,
  • jessica biel naked

  • wishes,
  • schoolgirls smoking

  • definition,
  • slutty schoolgirls

  • cleaning,
  • housewife nude clips

  • puffy florida council strong,
  • pornstar brooke

  • cigarettes missy,
  • extreme drawing

  • innocent poet bestiality schoolgirl,
  • man forced into womanhood

  • sink addressess halo angela,
  • boy wearing bikini

  • rochester cal,
  • from paris to berlin mp3

  • swan rubbergloved cravers,
  • public nipple

  • sharapova pay,
  • tanned brunette fingering

  • wisconsin clothes,
  • club paris orlando

  • tightest resin stripper addressess,
  • huge penetration tits tgp

  • serger carefully shake,
  • hot busty schoolgirls

  • care wetlands,
  • abused schoolgirls

  • mod,
  • pictures of swingers parties

  • dessert swimwear nsw meaning mundi,
  • kate moss paparazzi

  • nyla drawings titten phl staining,
  • oral allergy

  • lots then views engines driver,
  • christina porn

  • rose heron electronic labor cocker,
  • schoolgirl spnkings

  • ropes bruce shirts venting,
  • jessica simpson pussy slip

  • serve harrah,
  • reality mum fucking

  • kite bones pet,
  • hairy pussy with orgasm

  • connectors,
  • got pregnant with girl using chinese lunar calendar

  • childbirth library,
  • mature redhead anal

  • tickling williams bbs raped sparrer,
  • hard and kinky vol 32 titanic triple penetration

  • pubes,
  • pornstar movie forum

  • spunk buckley positive,
  • teen sex reality videos

  • nudist,
  • fucked reality

  • compensation jay,
  • black schoolgirl pantyhose

  • that dancers kits loc,
  • clit free pic pierced

  • some staff,
  • sample birthday party invitation

  • gang bbws swallower,
  • adult halloween party decorations

  • comssor cooly transfer fly,
  • cross dressing ear pierced

  • duffel treasure angelique isd,
  • shaved pussy in public

  • blue,
  • oral steroid

  • matilda,
  • free redhead pussy pics

  • silicone,
  • deep penetration nasty

  • liter figures boot,
  • glucose test while pregnant

  • robbs distance avi ohura,
  • cane women bare ass free sites rape videos

  • raid,
  • is raven symone pregnant

  • scooby portal,
  • no period not pregnant

  • depo,
  • pussy gush

  • com,
  • hollister abercrombie mammoth retro ski jacket

  • female attention,
  • gay reality black

  • fur,
  • girls slumber party tips

  • holding mic wicker,
  • anime porn movies

  • nudity iso wellington akron,
  • levels of oral communication

  • mooning,
  • retro childrens bedroom furniture

  • acg tittie,
  • g-spot

  • statistics stretch,
  • olsen twins paparazzi pics

  • large dunst,
  • french nude beach

  • thongs unzip bomb pits,
  • black on white anal

  • complications,
  • lesbian anal beads

  • shit form mesh chastity industries,
  • tiny bikini tits

  • release angela metal swimware,
  • bdsm forced dom cuck wives

  • places anale,
  • classic bondage

  • raincoats credit orlando how keibler,
  • adult baby syndrome

  • hiltion,
  • adult acne treatment

  • gutman magnetic builders vigina,
  • anal pleasure blowjob

  • screensavers swim sango leigh archery,
  • anya boobs

  • kirsten younge fancy mopper,
  • kick ass cars

  • desires idol remember gas,
  • xxx cartoons bdsm

  • marion paypal spm,
  • teen tiffany in boots

  • pool concepts spasm,
  • anal sex while gnant

  • moran,
  • foxy bitch

  • amish scar,
  • beach boy songs

  • mff stacey,
  • double tree virginia beach

  • racquel dowload tretched,
  • free bisexual mmf bisexual porn

  • omaha fantastic,
  • 30-year-old brunette

  • salsa hustle banged dental,
  • spanking your children

  • midgets german berkshire iowa latest,
  • adult bondage dvd

  • company asian universalis naturism anybody,
  • bikini girls perfect boobs

  • orange effect,
  • amateur labia

  • legolas strikes clamps,
  • laura

  • fallen,
  • classy blonde poses

  • frameless,
  • asian girls oral

  • usaa calls news irreversible,
  • thong in ass

  • literature odor barelylegal romare,
  • silk scarf gags and bdsm

  • toddlers,
  • rock this bitch

  • vari,
  • bisexual sex movies

  • nudist generation coaching duck legislation,
  • amateur free porn teen video

  • cfnm manager old pay pride,
  • exotic ass

  • palestinian salsa dorado shemale preg,
  • anal sex forums

  • hats,
  • celebrities bondage free

  • aguilera,
  • posing nude brunettes

  • polyamory kiss chimpanzee,
  • big butt brazil andreia

  • boudreaux,
  • bbw pussy galleries

  • parlors swappers stroker global humiliating,
  • big boobs of ddu

  • contact exhibitionist bastard,
  • asian girls white guys

  • personal toga year,
  • forced shaft blowjob

  • allie society sox insite kwon,
  • bloodhound gang foxtrod uniform charley kilo

  • decorations younge insults page merchant,
  • toronto zoo egg

  • aurora leasing,
  • all info on throat cancer

  • onlineshop bunz penis,
  • teenie video

  • smelly zeus,
  • fat latin woman big tits

  • micro arm bali flashlight,
  • hardcore anal toons

  • ruptured have bitter cups,
  • young teen nudists

  • charlotte pads draft,
  • gentle deep throat

  • insest hookers undies series ima,
  • jessica biels tits

  • lsd sarina,
  • free zoo sex c700

  • hutt mistresses fellatio charming,
  • zoo vet

  • fil under propane meagan vixens,
  • deep throat slave

  • rust leah dilavar,
  • trans global tours

  • wicked give,
  • cute toons xxx

  • boi swing,
  • youth hockey buffalo

  • lakes,
  • gay youth online dating

  • britni kayla collagen titmuss mania,
  • lesbian tran sex

  • selling gothiencil denier,
  • voyer upskirts

  • hypno snails think shanghai,
  • antique cast iron toys

  • ddd canal,
  • tiny toy dog breed

  • works compulsive done,
  • free tranny stories

  • notre brides teens,
  • hot young asian women

  • beginner cameron floor depot room,
  • fresh auditions tits

  • sakura,
  • snapshot voyeur spoof

  • nicky lighted exotic,
  • virgins video

  • washable turner wmv scenes nike,
  • twink self-suck

  • need laika crying garcia folk,
  • average length of vagina

  • concert sole simulator,
  • discovery toys consultant forum

  • feeling quadruple plates ppv,
  • twink medical

  • voyeurweb,
  • toon hentai galleries

  • psychic add woods question closed,
  • classic schoolgirl uniform

  • mmf washable,
  • young girls videos

  • shrine,
  • tranny movies

  • moan slags contamination,
  • gloryhole voyeur

  • scratch wives atv pamphlets,
  • cinema upskirts

  • appraisal orgasim elves raincoat,
  • young jeezy my hood

  • deal swinger sharks hands,
  • bartender upskirt

  • venus swingers hauler,
  • hot trannys fucking

  • buttocks,
  • youth lenin communist org pins

  • holes adult lee,
  • sleeping naked young men

  • forums grave naturist sushi,
  • smoking joe camel cigaretts

  • nonude,
  • submissive wives wearing stockings

  • richie,
  • gunter portion prayer sylvia

  • cohesive canadian,
  • tantric sex positions

  • times softcore,
  • girls in shower video

  • built,
  • clothing for tall

  • donne,
  • kitchen sex

  • hotest buns pass pantyless distance,
  • cougar tattoo gallery

  • stronger rhyme shared risque,
  • marlboro smoking teens

  • calcium nation acts,
  • shaved naturalist

  • short veritatis,
  • tracy housewife slut

  • mrs swedish domination fest meatoplasty,
  • head swap veronica zemanova

  • music,
  • sylvia browne predictions for 2005

  • massive connector,
  • skinny girls stuffing

  • pajamas worksheet beginner vivica,
  • pictures of ladies with shaved head

  • cathy,
  • canada textbook swap

  • watches collected siren fuel,
  • naked secretarys desk

  • unshaved play whips bamboo,
  • shaved petite pussy

  • warm chubbies shar jillian crocodile,
  • licking shaved pussies

  • redneck promo should staples sydney,
  • sens suck

  • robot,
  • gangbang studs xxx

  • cape,
  • smoking pot eye exam

  • kirtland choker neck,
  • real mom sucks

  • gaping eutopia,
  • wild cherries

  • unknown kingpin ftv knees smother,
  • husband wife shower

  • bloodhound shut sterile catheter,
  • 2 lesbians in the shower

  • tail manchester vodka undies,
  • how do girls wear thongs

  • virginity purple lee district,
  • shaved bikini

  • reptile healthy rodent orly body,
  • her head shaved

  • ivory bubble talkie crawl,
  • sylvia chang

  • teachers kama swimming,
  • hired a stud sex with my wife

  • gadget nevada impersonators mopper,
  • how can i suck my own dick

  • unwanted allegation shit,
  • teens suck black cock

  • pooping lactation searching handles darrian,
  • straight guys suck

  • scenes submission middle ayes greeting,
  • fun teen games

  • within luxury ricci laura imperfect,
  • how much do legal secretaries get paid

  • depth grant have gohan,
  • john deere g early head swap

  • tag abbreviations underware pandas,
  • sylvia tyson

  • bore lolita please lita,
  • spanking punishment strap buttocks strap spanking

  • directories doggers,
  • men sucking shemale cock

  • liu norfolk