jonhoranic / theGraveyard

Here is where the Graveyard archiving project begins! Welcome to everyone wishing to contribute.
3 stars 1 forks source link

age ranges #27

Open laurenmcguigan opened 7 years ago

laurenmcguigan commented 7 years ago

@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?

RJP43 commented 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).

ebeshero commented 7 years ago

@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.

laurenmcguigan commented 7 years ago

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]

ebeshero commented 7 years ago

@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.

laurenmcguigan commented 7 years ago

Awesome! It worked. Thank you!

laurenmcguigan commented 7 years ago

So now how do I say or? For example: lt or eq to 2

ebeshero commented 7 years ago

Scroll to the bottom of this page and you'll see it: http://dh.obdurodon.org/functions.xhtml Handy list of comparison operators!

laurenmcguigan commented 7 years ago

got it! So now how do you say a range so ge 80 and lt 90

RJP43 commented 7 years ago

@laurenmcguigan why not two predicates ?

laurenmcguigan commented 7 years ago

duh!

laurenmcguigan commented 7 years ago

thank you hahaha

ebeshero commented 7 years ago

Even better, unify them in one predicate using "and"!

laurenmcguigan commented 7 years ago

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>
laurenmcguigan commented 7 years ago

or should I be creating variables for them since I will do male vs female later?

RJP43 commented 7 years ago

I was thinking that.

laurenmcguigan commented 7 years ago

ok, no problem! Thank you!