Solved

Help with XSL

Posted on 2012-03-22
7
292 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
  • 4
  • 3
7 Comments
 
LVL 60

Expert Comment

by:Geert Bormans
Comment Utility
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
Comment Utility
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
Comment Utility
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
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 

Author Comment

by:Midani22
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
SPLUNK REST  API call to Splunk to create and index? 2 65
countPairs challenge 7 57
word0 challenge 3 55
recursion example 16 65
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.
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
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.

728 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now