Solved

Help with XSL

Posted on 2012-03-22
7
296 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
How our DevOps Teams Maximize Uptime

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us. Read the use case whitepaper.

 

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

Guide to Performance: Optimization & Monitoring

Nowadays, monitoring is a mixture of tools, systems, and codes—making it a very complex process. And with this complexity, comes variables for failure. Get DZone’s new Guide to Performance to learn how to proactively find these variables and solve them before a disruption occurs.

Question has a verified solution.

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

Suggested Solutions

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…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
The viewer will learn how to implement Singleton Design Pattern in Java.
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.
Suggested Courses

710 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