Harken: You fought with Captain Reynolds in the war? Zoe: Fought with a lot of people in the war. Harken: And your husband? Zoe: Fight with him sometimes, too.

'Bushwhacked'


Buffistechnology 2: You Made Her So She Growls?  

Got a question about technology? Ask it here. Discussion of hardware, software, TiVos, multi-region DVDs, Windows, Macs, LINUX, hand-helds, iPods, anything tech related. Better than any helpdesk!


tommyrot - Mar 27, 2006 8:01:16 am PST #7706 of 10003
Sir, it's not an offence to let your cat eat your bacon. Okay? And we don't arrest cats, I'm very sorry.

Anyone here know xsl?


le nubian - Mar 27, 2006 8:02:28 am PST #7707 of 10003
"And to be clear, I am the hell. And the high water."

no, but I know xxx.

(sorry)


Tom Scola - Mar 27, 2006 8:07:42 am PST #7708 of 10003
Remember that the frontier of the Rebellion is everywhere. And even the smallest act of insurrection pushes our lines forward.

Anyone here know xsl?

A little.


Gudanov - Mar 27, 2006 8:08:04 am PST #7709 of 10003
Coding and Sleeping

I've used and written a little simple xsl, but it's not something I work with very often at all. I might be able to help if it's a pretty simple question.


tommyrot - Mar 27, 2006 8:16:15 am PST #7710 of 10003
Sir, it's not an offence to let your cat eat your bacon. Okay? And we don't arrest cats, I'm very sorry.

I don't know if I can even explain this correcly....

OK, say we have the xsl:

<xsl:template match="/">
	<xsl:for-each select="employees/employee[@g=0]">
		<option>
			<xsl:attribute name="value"><xsl:value-of select="@i"/></xsl:attribute>
			<xsl:value-of select="@n"/> - <xsl:value-of select="status/@s" />
		</option>
	</xsl:for-each>
</xsl:template>

I want the stuff in the for-each loop to only happen if the

xsl:value-of select="status/@s"

actually matches something.

There's more stuff going on, but hopefully this is enough info....

eta: the <option> stuff is only there because this is returning html that's used in a drop-down box.


Tom Scola - Mar 27, 2006 8:19:41 am PST #7711 of 10003
Remember that the frontier of the Rebellion is everywhere. And even the smallest act of insurrection pushes our lines forward.

Easy-peasy.

<xsl:template match="/">
	<xsl:for-each select="employees/employee[@g=0]">
          <xsl:if test="status/@s">
		<option>
			<xsl:attribute name="value"><xsl:value-of select="@i"/>
			<xsl:value-of select="@n"/> - <xsl:value-of select="status/@s" />
		</option>
          </xsl:if>
	</xsl:for-each>
</xsl:template>

Although if it's more complicated than that, you'll probably end up having to use an t xsl:choose instead of an t xsl:if

.


tommyrot - Mar 27, 2006 8:25:02 am PST #7712 of 10003
Sir, it's not an offence to let your cat eat your bacon. Okay? And we don't arrest cats, I'm very sorry.

Thanks - I'll give that a try.

That was the direction I was going in, but I didn't know about the

<xsl:if test=

stuff....


tommyrot - Mar 27, 2006 8:50:13 am PST #7713 of 10003
Sir, it's not an offence to let your cat eat your bacon. Okay? And we don't arrest cats, I'm very sorry.

OK, that's not working, so I'll have to explain the (more) confusing stuff.

The thing is, the

xsl:value-of select="status/@s"

would normally match to multiple rows, except that there's a criteria/filter put on the xsl by the javascript that applies the xsl on the xml.

That looks like this:

xslStyle.loadXML(xslEmployeeComboboxDept.XMLDocument.xml);
selectField = xslStyle.selectSingleNode("//xsl:value-of[@select='status/@s']/@select");
selectField.value = "status[@pp=" + varPayPeriod + "]/@s"	
		
strTemp = xmlMaster.transformNode(xslStyle);

xslEmployeeComboboxDept is the stylesheet where I excerpted the above xsl.

I don't fully understand how this works, but it normally limits

xsl:value-of select="status/@s"

to a single match. Sometimes there are no matches, which is what i want to exclude....


Tom Scola - Mar 27, 2006 9:07:54 am PST #7714 of 10003
Remember that the frontier of the Rebellion is everywhere. And even the smallest act of insurrection pushes our lines forward.

That's very weird, tommyrot.

Edit: Basically, what the original programmer is doing is modifying the stylesheet on the fly, so that the stylesheet that is executed will be different than what the code you see.

Very kludgy.


Tom Scola - Mar 27, 2006 9:48:50 am PST #7715 of 10003
Remember that the frontier of the Rebellion is everywhere. And even the smallest act of insurrection pushes our lines forward.

Tommyrot, what I would do is get rid of the lines:

selectField = xslStyle.selectSingleNode("...");
selectField.value = "status[@pp=" + varPayPeriod + "]/@s"

replace it with:

xslStyle.addParameter("varPayPeriod", varPayPeriod);

add a

<xslt:param name="varPayPeriod"/>

to the beginning of your .xsl file, and change the

<xsl:value-of select="status/@s" />

to

<xsl:value-of select="status[@pp=$varPayPeriod]/@s" />

and use

<xsl:if test="status[@pp=$varPayPeriod]/@s" />

You have my permission to go and beat the original programmer with a stick.

(I might not have the syntax correct, you might have to use @pp='$varPayPeriod' with single quotes)