Open laurenmcguigan opened 7 years ago
@laurenmcguigan See if you can set up a predicate statement that indicates ages that have a value equal to or less than your number (like 2 for your above example).
@laurenmcguigan You could also set up a conditional test in XSLT, using <xsl:choose>
with <xsl:when>
statements inside. You put an @test
on <xsl:when>
to make it basically the predicate that Becca describes.
Alright, this is what I am doing to try and grab the ranges, but it is giving me an error in Xpath. It looks like this: //person[@role = 'occupant']//age[text() lt 2]
@laurenmcguigan It's probably giving you a type error, because text() isn't comparable to a number. So, you can convert it into a number with number()
... How to format it? number(.) or number(), try either way.
Awesome! It worked. Thank you!
So now how do I say or? For example: lt or eq to 2
Scroll to the bottom of this page and you'll see it: http://dh.obdurodon.org/functions.xhtml Handy list of comparison operators!
got it! So now how do you say a range so ge 80 and lt 90
@laurenmcguigan why not two predicates ?
duh!
thank you hahaha
Even better, unify them in one predicate using "and"!
quick question: Is there an easier way to write out the value for y1 other than writing out the whole test again? I tried current() but that isn't working.
<xsl:choose>
<xsl:when
test="//person[@role = 'occupant']//age[number() le 60 and number() gt 50]">
<line x1="{$xPos}"
y1="{count(//person[@role = 'occupant']//age[number() le 60 and number() gt 50]) * $xSpacer}"
x2="{$xPos}" y2="0" style="stroke:black; stroke-width:35"/>
</xsl:when>
</xsl:choose>
or should I be creating variables for them since I will do male vs female later?
I was thinking that.
ok, no problem! Thank you!
@RJP43 @ebeshero Hi again! I am working on creating a visualization of ages of death, but would like to output ranges. This is how I output the ages
//person[@role = 'occupant']//age
how would I do a range, say 0 to 2?