Skip to content

Instantly share code, notes, and snippets.

@sardinecan
Created December 16, 2020 16:42
Show Gist options
  • Save sardinecan/2aa8ce044a9f0025d6da7eaa1603743c to your computer and use it in GitHub Desktop.
Save sardinecan/2aa8ce044a9f0025d6da7eaa1603743c to your computer and use it in GitHub Desktop.
XsltForms issues
<?xml-stylesheet href="xsltforms.xsl" type="text/xsl"?>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:xf="http://www.w3.org/2002/xforms" xmlns:foo="foo" foo:bogus="ff fix">
<head>
<title>Rock with XForms !</title>
<xf:model>
<xf:instance id="music">
<data xmlns="foo">
<rockBand/>
<album n="1"/>
<album n="2"/>
</data>
</xf:instance>
<xf:bind nodeset="foo:rockBand" required="true()"/>
<xf:bind nodeset="foo:album" required="true()" relevant="instance('music')/foo:rockBand[. != '']"/>
<xf:instance id="bands">
<bands xmlns="foo">
<band>Led Zeppelin</band>
<band>Cream</band>
</bands>
</xf:instance>
<xf:instance id="album">
<albums xmlns="foo">
<album n="1">
<title>Led Zeppelin</title>
<band>Led Zeppelin</band>
<track>Good Times Bad Times</track>
<track>Babe I'm Gonna Leave You</track>
<track>You Shook Me</track>
<track>Dazed and Confused</track>
<track>Your Time Is Gonna Come</track>
<track>Black Mountain Side</track>
<track>Communication Breakdown</track>
<track>I Can't Quit You Baby</track>
<track>How Many More Times</track>
</album>
<album n="2">
<title>Led Zeppelin II</title>
<band>Led Zeppelin</band>
<track>Whole Lotta Love</track>
<track>What Is and What Should Never Be</track>
<track>The Lemon Song</track>
<track>Thank You</track>
<track>Heartbreaker</track>
<track>Living Loving Maid (She's Just a Woman)</track>
<track>Ramble On</track>
<track>Moby Dick</track>
<track>Bring It On Home</track>
</album>
<album n="1">
<title>Fresh Cream</title>
<band>Cream</band>
<track>N.S.U.</track>
<track>Sleepy Time Time</track>
<track>Dreaming</track>
<track>Sweet Wine</track>
<track>Spoonful</track>
<track>Cat's Squirrel</track>
<track>Four Until Late</track>
<track>Rollin' and Tumblin</track>
<track>I'm So Glad</track>
<track>Toad</track>
</album>
<album n="2">
<title>Disraeli Gears</title>
<band>Cream</band>
<track>Strange Brew</track>
<track>Sunshine of Your Love</track>
<track>World of Pain</track>
<track>Dance the Night Away</track>
<track>Blue Condition</track>
<track>Tales of Brave Ulysses</track>
<track>SWLABR</track>
<track>We're Going Wrong</track>
<track>Outside Woman Blues</track>
<track>Take It Back</track>
<track>Mother's Lament</track>
</album>
</albums>
</xf:instance>
</xf:model>
</head>
<body>
<xf:select1 ref="foo:rockBand" incremental="true">
<xf:label>Choose your favorite rock band (xf:label w/ @ref): </xf:label>
<xf:itemset nodeset="instance('bands')/foo:band">
<xf:label ref="."/>
<xf:value ref="."/>
</xf:itemset>
</xf:select1>
<br/>
<xf:select1 ref="foo:rockBand" incremental="true">
<xf:label>Choose your favorite rock band (xf:label w/ @value, label not displayed): </xf:label>
<xf:itemset nodeset="instance('bands')/foo:band">
<xf:label value="concat('band ', .)"/>
<xf:value ref="."/>
</xf:itemset>
</xf:select1>
<!--issue with label and need multiple click to select a value, impossible to selecte multiple value (select)-->
<xf:repeat id="repeatAlbum" nodeset="foo:album">
<xf:var name="album" value="."/>
<xf:label><xf:output value="concat('Choose your favorite tracks from ', instance('album')/foo:album[@n=$album/@n][foo:band = instance('music')/foo:rockBand]/foo:title, ' (with xf:copy)')"/></xf:label>
<xf:select ref="." appearance="full">
<xf:itemset nodeset="instance('album')/foo:album[@n=$album/@n][foo:band = instance('music')/foo:rockBand]/foo:track">
<xf:label ref="."/>
<xf:copy ref="."/>
</xf:itemset>
</xf:select>
</xf:repeat>
<xf:repeat id="repeatAlbum" nodeset="foo:album">
<xf:var name="album" value="."/>
<xf:label><xf:output value="concat('Choose your favorite tracks from ', instance('album')/foo:album[@n=$album/@n][foo:band = instance('music')/foo:rockBand]/foo:title, ' (with xf:value)')"/></xf:label>
<xf:select ref="." appearance="full">
<xf:itemset nodeset="instance('album')/foo:album[@n=$album/@n][foo:band = instance('music')/foo:rockBand]/foo:track">
<xf:label ref="."/>
<xf:value ref="."/>
</xf:itemset>
</xf:select>
</xf:repeat>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment