Solved

Help with XSL

Posted on 2012-03-22
7
297 Views
Last Modified: 2012-08-14
<xsl:variable name="parentId" select="substring-before(substring-after(concat($querystring, '&'), 'parentid='), '&')"/>

If the variable name is a session already available to the application, is the above needed?


<xsl:if test="@id = 'SelectReporting' and not(contains('#2#10#192#15#169#189#230#', concat('#', $parentid, '#')))">

if I want to keep parentid and not concatenate, how do I edit the above, also do I need the last "#" on the above referenced line?

thanks, M.
0
Comment
Question by:Midani22
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
7 Comments
 
LVL 60

Expert Comment

by:Geert Bormans
ID: 37754302
preferably you pass the parentid in from the caller to teh XSLT other than the query string.
No you don't need that substring operation then

you don't concatenate the parentid,
you just concatenate a "#" before and after temporarily in order to do the compare
you need all the hashes as in my example to not have false hits

if parent id would be "23" and you don't test for "#23#" but "#23" instead
you would get a false hit on the #230#
0
 

Author Comment

by:Midani22
ID: 37754387
This is an example of what another developer did:

<!--xsl:if test="@id='SelectReporting' and not($state='FL')">
                                                <xsl:attribute name="STYLE">display:none</xsl:attribute>
</xsl:if-->
                   

This is what you said I think you said:

<xsl:if test="@id = 'SelectReporting' and not(contains('#2#10#192#15#169#189#230#', concat('#', $parentid, '#')))">
<xsl:attribute name="STYLE">display:none</xsl:attribute>
</xsl:if>

If this is not it, can you elaborate one last time? Thanks, Michele
0
 
LVL 60

Accepted Solution

by:
Geert Bormans earned 500 total points
ID: 37754542
What the other developer did, assumes a compare against one single value

what I wrote is a string processing trick to not have to write

<xsl:if test="@id = 'SelectReporting' and not($parentid = 2 or $parentid = 10 or $parentid = 192 or $parentid = 15 or $parentid = 169 or $parentid = 189 or $parentid = 230)">
I thought that was what you needed
both render teh same result
0
Containers & Docker to Create a Powerful Team

Containers are an incredibly powerful technology that can provide you and/or your engineering team with huge productivity gains. Using containers, you can deploy, back up, replicate, and move apps and their dependencies quickly and easily.

 

Author Comment

by:Midani22
ID: 37754687
The parentid is not present in the xml file. How do I trace it and show it?

The xml is below:
NavBar.xsl
0
 
LVL 60

Expert Comment

by:Geert Bormans
ID: 37754767
Well Michele, that is something I can't possibly know. That is information you should give me before I can help.

Can you briefly explain what this application does?

I understand you have a servlet and that servlet gets a request?
Do you want information from that request passed on to the XSLT process?
Your servlet will have knowledge about the query string and can split it out in parameters
These parameters can be passed to your stylesheet by addParam (or something similar, I am not a Java programmer)

Or does you parentid needs to be calculated from values in the XML or one of the parameters? Then I need info on where to get it from

I see you made the parentid a variable in the XSLT. If you want to pass it in, it should be an xsl:param, not a xsl:variable
0
 

Author Comment

by:Midani22
ID: 37754845
Do you want information from that request passed on to the XSLT process?
yes

the servlet does not specifically reference the parentid however, I have not mentioned it in the xls file and finally, it does not properly show these values against the previously written xsl statement that you worked on earlier today.

The servlet is attached.

We wondered how we would be able to properly reference the parentid in the .xls file and get it to show. We had no problems with this one for instance:

</xsl:if>
                    <!--xsl:if test="@id='SelectReporting' and not($state='FL')">
                                                <xsl:attribute name="STYLE">display:none</xsl:attribute>
doLogin.java
0
 
LVL 60

Expert Comment

by:Geert Bormans
ID: 37754945
well main difference is that state is a parameter and parentId is a variable (note that names are case sensitive in XML)

The java you send me does not have code for processing the XSLT, so there is no way I can reference the process in it
0

Featured Post

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

623 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question