Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

age ranges #27

Open
laurenmcguigan opened this issue Dec 11, 2016 · 16 comments
Open

age ranges #27

laurenmcguigan opened this issue Dec 11, 2016 · 16 comments

Comments

@laurenmcguigan
Copy link
Collaborator

@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
Copy link
Collaborator

RJP43 commented Dec 11, 2016

@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
Copy link
Collaborator

@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
Copy link
Collaborator Author

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
Copy link
Collaborator

ebeshero commented Dec 11, 2016

@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
Copy link
Collaborator Author

Awesome! It worked. Thank you!

@laurenmcguigan
Copy link
Collaborator Author

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

@ebeshero
Copy link
Collaborator

ebeshero commented Dec 11, 2016

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

@laurenmcguigan
Copy link
Collaborator Author

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

@RJP43
Copy link
Collaborator

RJP43 commented Dec 11, 2016

@laurenmcguigan why not two predicates ?

@laurenmcguigan
Copy link
Collaborator Author

duh!

@laurenmcguigan
Copy link
Collaborator Author

thank you hahaha

@ebeshero
Copy link
Collaborator

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

@laurenmcguigan
Copy link
Collaborator Author

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
Copy link
Collaborator Author

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

@RJP43
Copy link
Collaborator

RJP43 commented Dec 11, 2016

I was thinking that.

@laurenmcguigan
Copy link
Collaborator Author

ok, no problem! Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants