GithubHelp home page GithubHelp logo

Confused about dhclass-hub HOT 59 CLOSED

ebeshero avatar ebeshero commented on July 25, 2024
Confused

from dhclass-hub.

Comments (59)

RJP43 avatar RJP43 commented on July 25, 2024

To select on anything using XSLT <xsl:apply-templates select="..."/> you are going to need to write an XPath function and you know how to get to attributes using XPath. So there should be no real problem for you to grab attributes. The question is asking you to make a match and initial selection on the elements that are bound together with similar responses (the yes and no questions). Check out the last issue Nicole posted and maybe this will give you some insight.

from dhclass-hub.

CodyKarch avatar CodyKarch commented on July 25, 2024

I understood what you referenced, but I still can't comprehend what is told in the instructions mentioned above (and additionally, now, number 3: In the <xsl:template> rules for <string> elements of the <f name="question"> you’ll need to output something for each one, that is, each question that has a β€œYes” answer (held inside the same <fs> element as the <f name="response"> with @select="Yes").). I feel like if I understood those, I could continue along.

from dhclass-hub.

RJP43 avatar RJP43 commented on July 25, 2024

The assignment is having you take note of what is bound together and how you make selections on information while keeping what is bound together... together.

Ok let's walk through this then ... what do you need to select to get only the questions and answers that contain a possible yes/no response?

from dhclass-hub.

CodyKarch avatar CodyKarch commented on July 25, 2024

Well, I was able to collect the questions with: <tr> <td><xsl:apply-templates select="f[@name='question']/string"/></td> </tr> and I know that if I want to collect more info, I need to put another apply-template in another set of elements; right?

from dhclass-hub.

RJP43 avatar RJP43 commented on July 25, 2024

Ok so what is really great about our <fs> structure is that all the information for one <tr> are in the same <fs> so if you do a match that grabs a <fs> that contains a possible response of yes or you could choose no or any other response that is specific to yes or no questions then all of your selections <apply-templates select=".."/> can be made inside of that one match and for each selection you would open a new <td> inside of that same <tr> inside of that one match... looks like you get it with your selection for grabbing the questions. It is hard for me to judge what you have with your matches and understand where you are getting confused without your file. Consider pushing to the troubleshooting folder if I am not being helpful enough and perhaps I can be of more help.

from dhclass-hub.

nlottig94 avatar nlottig94 commented on July 25, 2024

You need to fix something in your firstxsl:apply-templates select="....." You're being way too greedy just grabbing the <fs> elements....try digging down deeper!

from dhclass-hub.

CodyKarch avatar CodyKarch commented on July 25, 2024

Into the attributes?

from dhclass-hub.

RJP43 avatar RJP43 commented on July 25, 2024

exactly so in both your first select and your first match you are saying give me all the <fs> you only want the <fs> that have certain responses ... this is a predicate issue

from dhclass-hub.

nlottig94 avatar nlottig94 commented on July 25, 2024

Yes and no. You first want to go down into <f> elements and then you want to select different attributes to make your search more specific..

from dhclass-hub.

nlottig94 avatar nlottig94 commented on July 25, 2024

I was telling the XSLT to give me all of the elements in the <div> element. I was using a greedy selection because it was too much.
I needed to find the more specific XPath of grabbing all of the <fs> elements that have <f> elements which have @name="response" and @select="no". This will grab all of the yes and no questions because the yes is bound to the no.

from dhclass-hub.

CodyKarch avatar CodyKarch commented on July 25, 2024

Okay, I'm really trying here. I need to change the apply-template which is within the

? Or do I need to change the template after my HTML?

from dhclass-hub.

CodyKarch avatar CodyKarch commented on July 25, 2024

Sorry <table?

from dhclass-hub.

RJP43 avatar RJP43 commented on July 25, 2024

both ... but you need to understand your first selection before you start to thinking about what you would select later.

from dhclass-hub.

CodyKarch avatar CodyKarch commented on July 25, 2024

So would <xsl:apply-templates select="//fs/f"> be suitable for the first one?

from dhclass-hub.

CodyKarch avatar CodyKarch commented on July 25, 2024

Or do I need more on that?

from dhclass-hub.

blawrence719 avatar blawrence719 commented on July 25, 2024

You need more than that. You need to go deeper into your <fs> and say exactly which <f> you are trying to grab for your table.

from dhclass-hub.

RJP43 avatar RJP43 commented on July 25, 2024

yes! and remember what I hinted to about using a predicate so you don't step down any further but you do specify what <f> you want

from dhclass-hub.

CodyKarch avatar CodyKarch commented on July 25, 2024

So, I keep testing different things, but it keeps popping up "Infinite Loop Detected"; what does this mean?

from dhclass-hub.

RJP43 avatar RJP43 commented on July 25, 2024

show me what you are testing just copy it here into this issue with tics ..

from dhclass-hub.

RJP43 avatar RJP43 commented on July 25, 2024

you were on the right track with going into the <f> of the <fs> <xsl:apply-templates select="//fs/f"> just take it further by specifying what <f> responses your table is specifically looking for using predicates

from dhclass-hub.

CodyKarch avatar CodyKarch commented on July 25, 2024
      ` <table>
                <tr>
                    <th>Number</th>
                    <th>Question</th>
                    <th>Yes</th>
                    <th>Yes, but fined</th>
                    <th>No</th>
                    <th>Blank</th>
                    <th>Total Responses</th>
                </tr>
                <tr>

                </tr>
                <xsl:apply-templates select="//fs/f[@name='response']"></xsl:apply-templates>
            </table>

        </body>

    </html>

</xsl:template>

<xsl:template match="//fs/f[@name='response']">

    <tr> 
        <td><xsl:apply-templates select="//fs/f[@select='Yes']"/></td>


    </tr>
</xsl:template>`

from dhclass-hub.

RJP43 avatar RJP43 commented on July 25, 2024

and consider that the / going into the f is saying you only want the <f> s in reality you want the <fs> that has the <f> that has the @select

from dhclass-hub.

RJP43 avatar RJP43 commented on July 25, 2024

where are you Cody? I am still on campus and I feel like this is an issue with how we are explaining it through typing that you aren't catching what we are hinting at ... I am in The Shaw with Brook and Nicole

from dhclass-hub.

RJP43 avatar RJP43 commented on July 25, 2024

You are getting closer ...

from dhclass-hub.

CodyKarch avatar CodyKarch commented on July 25, 2024

I'm in westmoreland. Would select="//fs/f[@select]" be right?

from dhclass-hub.

RJP43 avatar RJP43 commented on July 25, 2024

yes yes yes but @select= to what???? to get yes or no questions specifically and your first select will be almost identical to your first match so then all of your table cells will have info that is bound together in the same <fs>

from dhclass-hub.

CodyKarch avatar CodyKarch commented on July 25, 2024

and for all three spots shown above? or just the first?

from dhclass-hub.

RJP43 avatar RJP43 commented on July 25, 2024

so after you have selected and matched ... the selections you make in the single <td> elements will only have to specify exactly what you want like how you originally had for the question strings

from dhclass-hub.

RJP43 avatar RJP43 commented on July 25, 2024

you need to make the bind first then output each part of what is bound together and needs to be represented in the table cells

from dhclass-hub.

RJP43 avatar RJP43 commented on July 25, 2024

and in your first selection and match you are not trying to find the <f> elements you want the <fs> elements

from dhclass-hub.

RJP43 avatar RJP43 commented on July 25, 2024

by saying //fs/f you are saying give me all the <f> elements that come after <fs> elements you actually want to say give me all the <fs> elements that have <fs> that have @select=".." and the contents of the select will be a specific value either yes, no, or yes but fined so that you get the <fs> elements that are related to yes or no questions

from dhclass-hub.

RJP43 avatar RJP43 commented on July 25, 2024

pay special attention too that you spell the specific value you choose the same way it is spelled in the xml

from dhclass-hub.

CodyKarch avatar CodyKarch commented on July 25, 2024

Strangely, I have tried this ^mentioned above and every order I try with these doesn't work (in one manner or another)

from dhclass-hub.

RJP43 avatar RJP43 commented on July 25, 2024

predicate inside predicate is specifying the <fs> that has something that has something. From what I see you have the / which is stepping down into the <f>

from dhclass-hub.

CodyKarch avatar CodyKarch commented on July 25, 2024

So I need an fs that contains an f that contains a select attribute with either Yes or No ? Correct?

from dhclass-hub.

RJP43 avatar RJP43 commented on July 25, 2024

right but the contains are written how exactly .. show me in tics

from dhclass-hub.

CodyKarch avatar CodyKarch commented on July 25, 2024

//fs[f(@select='Yes')] ?

from dhclass-hub.

RJP43 avatar RJP43 commented on July 25, 2024

<xsl:apply-templates select="//fs[f thats good ....

from dhclass-hub.

RJP43 avatar RJP43 commented on July 25, 2024

and @select='yes' is good but needs to be in what to say the <f> that have those

from dhclass-hub.

RJP43 avatar RJP43 commented on July 25, 2024

predicate inside predicate is how you specify

from dhclass-hub.

CodyKarch avatar CodyKarch commented on July 25, 2024

So, instead of parenthesis, I would use square brackets?

from dhclass-hub.

RJP43 avatar RJP43 commented on July 25, 2024

yes!!!!! because we are talking predicates :) now read what you have in that selection and tell me how it is different from what you had ... its important you understand where this first match/select is putting you so you can make your other selections

from dhclass-hub.

CodyKarch avatar CodyKarch commented on July 25, 2024

So, would I want to have it like this:
1st: apply-templates select="//f[f[@select='Yes']]"
2nd: templates match="//f[f[@select='Yes']]"
3rd: apply-templates select="//f[f[@select='Yes']]"

Ps: I kind of wish I could have simply grasped the quotation I first posted.

from dhclass-hub.

RJP43 avatar RJP43 commented on July 25, 2024

well think about this once you make your second match you then want to start with outputting a new <tr> and all the <td> in the specific order of your <th> elements from above... this is why I was saying you were on the right track with grabbing your question strings once you have the right initial select and match

from dhclass-hub.

RJP43 avatar RJP43 commented on July 25, 2024

now that you have said I want the <fs> elements of a specific type you can say you want the question number, the question, each of the responses, and the sum of responses all in a single <tr> all inside that match that binds them together

from dhclass-hub.

RJP43 avatar RJP43 commented on July 25, 2024

go back to the assignment and i think u can figure it out from here

from dhclass-hub.

CodyKarch avatar CodyKarch commented on July 25, 2024

So:
1st: apply-templates select="//f[f[@select='Yes']]" *** I don't know what you mean by question number, I don't see any. ***
2nd: templates match="//f[f[@name='question']]"
3rd: apply-templates select="//f[f[@name='response']]"

from dhclass-hub.

ebeshero avatar ebeshero commented on July 25, 2024

@CodyKarch @RJP43 Careful, folks, with those // marks and where you're using them! Cody, I wonder if that was what was giving you the infinite loop problem. When you say
xsl:template match="something" that is not a literal XPath: it's a pattern. And you step down from that pattern inside the template rule when you do xsl:apply-templates select="something" or xsl:apply-templates select=".//something"
That dot notation is significant--and you may not need it here, but you need to remember how you're stepping from the template match (your context node) down into its children and/or descendants, or wherever you need to walk with XPath in your @select attribute.

from dhclass-hub.

ebeshero avatar ebeshero commented on July 25, 2024

@CodyKarch @RJP43 When you write
<xsl:apply-templates select="//f[ANYTHING]"/>
you are saying, GO BACK UP TO THE DOCUMENT NODE and run through the ENTIRE XML tree to get all these. Is that what you intended?

from dhclass-hub.

CodyKarch avatar CodyKarch commented on July 25, 2024

Well, isn't that saying descend to the f element and find specifically ANYTHING ?

from dhclass-hub.

ebeshero avatar ebeshero commented on July 25, 2024

Yes--and it'll probably work here, and might even get you the output you want--but it could get you TOO MUCH of that output, if you only want ANYTHING when it's a piece of a PARTICULAR fs element.

from dhclass-hub.

ebeshero avatar ebeshero commented on July 25, 2024

What I'm saying is, there's a simpler way to write your path steps here, if you're thinking about how XSLT template matches and apply-templates @select attributes work. Step down, parent to child to attribute.

from dhclass-hub.

CodyKarch avatar CodyKarch commented on July 25, 2024

So you want the most direct path to a specific thing?

from dhclass-hub.

ebeshero avatar ebeshero commented on July 25, 2024

Yep! πŸ‘

from dhclass-hub.

ebeshero avatar ebeshero commented on July 25, 2024

Keep it simple so you don't make your processor loop around unnecessarily. Sometimes you may actually want to go back up to the document node, but do you really need to do that here?

from dhclass-hub.

CodyKarch avatar CodyKarch commented on July 25, 2024

No. You're setting a place within the HTML with your apply-template, giving it a governing rule of which is a connecting template, and pulling out your information with another apply-template. And you wouldn't want an indirect path for any of those. Correct?

from dhclass-hub.

ebeshero avatar ebeshero commented on July 25, 2024

Correct: There is no need of an indirect path.

from dhclass-hub.

CodyKarch avatar CodyKarch commented on July 25, 2024

SO should my XPath in the HTML and my XPath that starts a template be the same?

from dhclass-hub.

ebeshero avatar ebeshero commented on July 25, 2024

Maybe not exactly the same... but my solution doesn't have //'s in it.

from dhclass-hub.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.