[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 114
  • Last Modified:

XSL when test - need it to return zero results

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
doc_jay
Asked:
doc_jay
  • 2
1 Solution
 
mccarlIT Business Systems Analyst / Software DeveloperCommented:
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
 
doc_jayAuthor Commented:
thanks, just the tip I needed  :)
0
 
mccarlIT Business Systems Analyst / Software DeveloperCommented:
No worries, glad to help!!
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now