Solved

XSL when test - need it to return zero results

Posted on 2015-02-11
3
84 Views
Last Modified: 2015-02-12
HI --

   I have this stylesheet that I'm wanting to  run a string-lengh test in.  If all of the strings are of '0' length (an empty query by a user) then I want it to return zero results.  With out this in place it will do a blank query on the DB and return all results.

Here is what I have so far

<!-- New XML document created with EditiX XML Editor (http://www.editix.com) at Wed Feb 11 14:51:56 CST 2015 -->
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
	<xsl:output method="xml" indent="yes"/>
	<xsl:param name="calling" select="'AE_CALLING'"/>
	<xsl:param name="called" select="'DCM4CHEE'"/>
	<xsl:param name="date" select="'20051206'"/>
	<xsl:param name="time" select="'115600.000'"/>
	<xsl:template match="/dataset">
		<dataset>
			<xsl:variable name="studyDate" select="attr[@tag='00080020']"/>
			<xsl:variable name="studyTime" select="attr[@tag='00080030']"/>
			<xsl:variable name="accNumber" select="attr[@tag='00080050']"/>
			<xsl:variable name="mod" select="attr[@tag='00080061']"/>
			<xsl:variable name="refPhy" select="attr[@tag='00080090']"/>
			<xsl:variable name="studyDesc" select="attr[@tag='00081030']"/>
			<xsl:variable name="patName" select="attr[@tag='00100010']"/>
			<xsl:variable name="patId" select="attr[@tag='00100020']"/>
			<xsl:variable name="patDOB" select="attr[@tag='00100030']"/>
			<xsl:variable name="patSex" select="attr[@tag='00100040']"/>
			<xsl:variable name="studySuid" select="attr[@tag='0020000D']"/>
			<xsl:variable name="studyId" select="attr[@tag='00200010']"/>
			<xsl:variable name="numSrs" select="attr[@tag='00201206']"/>
			<xsl:variable name="numSri" select="attr[@tag='00201208']"/>
			<xsl:variable name="studyStatid" select="attr[@tag='0032000A']"/>
			<xsl:choose>
				<xsl:when test="((string-length($studyDate)=0) and (string-length($studyTime)=0) and (string-length($accNumber)=0) and (string-length($mod)=0) and (string-length($refPhy)=0) and (string-length($studyDesc)=0) and (string-length($patName)=0) and (string-length($patId)=0) and  (string-length($patDOB)=0) and (string-length($patSex)=0) and (string-length($studySuid)=0) and (string-length($studyId)=0) and (string-length($numSrs)=0) and (string-length($numSri)=0) and (string-length($studyStatid)=0))">
					<xsl:copy-of select="attr[@tag='0020000D']"/>
				</xsl:when>
				<xsl:otherwise/>
			</xsl:choose>
		</dataset>
	</xsl:template>
</xsl:stylesheet>

Open in new window


Here is the XML:

<?xml version="1.0" encoding="UTF-8"?><dataset>
<attr tag="00080020" vr="DA" pos="0" name="Study Date" vm="0" len="0"/>
<attr tag="00080030" vr="TM" pos="8" name="Study Time" vm="0" len="0"/>
<attr tag="00080050" vr="SH" pos="16" name="Accession Number" vm="0" len="0"/>
<attr tag="00080052" vr="CS" pos="24" name="Query/Retrieve Level" vm="1" len="6">STUDY</attr>
<attr tag="00080061" vr="CS" pos="38" name="Modalities in Study" vm="0" len="0"/>
<attr tag="00080090" vr="PN" pos="46" name="Referring Physician's Name" vm="0" len="0"/>
<attr tag="00081030" vr="LO" pos="54" name="Study Description" vm="0" len="0"/>
<attr tag="00100010" vr="PN" pos="62" name="Patient's Name" vm="1" len="0"/>
<attr tag="00100020" vr="LO" pos="82" name="Patient ID" vm="0" len="0"/>
<attr tag="00100030" vr="DA" pos="90" name="Patient's Birth Date" vm="0" len="0"/>
<attr tag="00100040" vr="CS" pos="98" name="Patient's Sex" vm="0" len="0"/>
<attr tag="0020000D" vr="UI" pos="106" name="Study Instance UID" vm="0" len="0"/>
<attr tag="00200010" vr="SH" pos="114" name="Study ID" vm="0" len="0"/>
<attr tag="00201206" vr="IS" pos="122" name="Number of Study Related Series" vm="0" len="0"/>
<attr tag="00201208" vr="IS" pos="130" name="Number of Study Related Instances" vm="0" len="0"/>
<attr tag="0032000A" vr="CS" pos="138" name="Study Status ID" vm="0" len="0"/>
</dataset>

Open in new window


When I do a blank query with this in place, it will return all results.  Maybe it would be a better idea to return a $studyDate  with a value of '19000101' as this should result with no results as well.

thanks for looking
0
Comment
Question by:doc_jay
  • 2
3 Comments
 
LVL 35

Accepted Solution

by:
mccarl earned 500 total points
ID: 40604972
I am bit confused by what you want and what you have posted, but I'll have a go...

I want it to return zero results.
What do you mean by zero results? Do you mean 0 <attr> elements in the <dataset> element in the output? If so, then I think there may be a few extra things that you need to sort out (as I said, it is confusing what you are doing) but I think at least that you are needing to have the "not" keyword at the start of your string length test, eg. <xsl:when test="not ((string-length...... So that when they are NOT all zero length you include a <attr> element but when they ARE all zero length, the not inverts that to false and so the <attr> element isn't in the output.

Is this what you are after? If not, then can you try to explain further what you need to happen. Often a good way to specify what you want is to come up with a couple of different input scenarios and manually generate what you expect the output to be. Then if you can post the input and expected output for those few scenarios then we can help get you the XSLT to make it happen!
0
 

Author Comment

by:doc_jay
ID: 40606685
thanks, just the tip I needed  :)
0
 
LVL 35

Expert Comment

by:mccarl
ID: 40606799
No worries, glad to help!!
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

The Client Need Led Us to RSS I recently had an investment company ask me how they might notify their constituents about their newsworthy publications.  Probably you would think "Facebook" or "Twitter" but this is an interesting client.  Their cons…
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 tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

747 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

11 Experts available now in Live!

Get 1:1 Help Now