Solved

Help with XSL

Posted on 2012-03-22
7
293 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
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
3 Use Cases for Connected Systems

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

 

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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
XML XSLT If loop 4 26
web application structure 18 76
Configure a Bean in an XML file 4 31
servlet example 17 29
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Many times as a report developer I've been asked to display normalized data such as three rows with values Jack, Joe, and Bob as a single comma-separated string such as 'Jack, Joe, Bob', and vice versa.  Here's how to do it. 
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

776 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