XSL Transformation problem

Place to talk about all that new hardware and decaying software you have.

Moderator: General Mods

Post Reply
Agozer
16-bit Corpse | Nyoron~
Posts: 3534
Joined: Sun Aug 01, 2004 7:14 pm
Location: Nokia Land

XSL Transformation problem

Post by Agozer »

So yeah, I having trouble with an XML --> XHTML transformation using XSL. More specifically I want to count the number of persons with specific data and then output the result.

My XML structure is akin to something like this:

Code: Select all

<people>

  <person>
	<name>Mary</name>
	<sex>Yes please</sex>
	<note>bring condoms, bring wine, wears expensive lingerie</note>
  </person>

  <person>
	<name>Felli</name>
	<sex>Yes please</sex>
	<note>loli with a twist, mean eye</note>
  </person>

  <person>
	<name>Helga</name>
	<sex>Hell no</sex>
	<note>Huge girth, hambeast, needs eyebleach</note>
  </person>

  <person>
	<name>Jenna</name>
	<sex>Yes please</sex>
	<note>bring wine, pornstar, blonde</note>
  </person>
...

etc. etc.

</people>
I'm trying to count (using XSLT count() function or any other suitable XSLT method) the number of persons with both the sex element containing "yes please" as well as the note element containing the words "bring wine". I have traversed the Intarwebs for months, steering away from porn, searching high and low, and have found lots of would-be examples, just not the one I'm looking for. All my past efforts have produced incorrect results or a result of 0, so there's something I'm doing wrong - I just can't figure out what.

The solution is most likely something incredibly easy.
whicker: franpa is grammatically correct, and he still gets ripped on?
sweener2001: Grammatically correct this one time? sure. every other time? no. does that give him a right? not really.
Image
funkyass
"God"
Posts: 1128
Joined: Tue Jul 27, 2004 11:24 pm

Post by funkyass »

which XML parser you using?

I have found that, at least for Microsoft's .NET parser, you need a namespace for Xpath to work properly.

count(/people/person) should do it, assuming there aren't more than one instance of people, then //person will work I think.
Does [Kevin] Smith masturbate with steel wool too?

- Yes, but don’t change the subject.
Agozer
16-bit Corpse | Nyoron~
Posts: 3534
Joined: Sun Aug 01, 2004 7:14 pm
Location: Nokia Land

Post by Agozer »

I'm using Altova XMLSpy 2008 and its ownl XML/XSLT parser.Yes, I've defined a namespace for XSL and XPath is working properly.

I have quite a few count() functions (I use them to display statistics), but this particular one is giving me trouble.
whicker: franpa is grammatically correct, and he still gets ripped on?
sweener2001: Grammatically correct this one time? sure. every other time? no. does that give him a right? not really.
Image
funkyass
"God"
Posts: 1128
Joined: Tue Jul 27, 2004 11:24 pm

Post by funkyass »

Xquery is what you may be after... it probably be less hassle to parse the XML and stuff it into an database, and let SQL be the magical thing it is.
Does [Kevin] Smith masturbate with steel wool too?

- Yes, but don’t change the subject.
Post Reply