Hi, Iam having problems with combining a xml/xsl documents into a txt output.
Code follows XML:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE jokeList [
<!ELEMENT jokeList (joke)*>
<!ELEMENT joke (setUp, punchLine)*>
<!ELEMENT setUp (#PCDATA)>
<!ELEMENT punchLine (#PCDATA)>
<!ATTLIST joke category (KnockKnock|lightbulb|crossing) "crossing" >
<!ATTLIST jokes stuff (setUp|punchLine) "setUp" >
]>
<jokeList>
-
<joke category="KnockKnock">
<setUp>
Amos
</setUp>
<punchLine>
A mosquito bit me
</punchLine>
</joke>
-
<joke category="lightbulb">
<setUp>
software engineers
</setUp>
<punchLine>
none, it's a hardware problem
</punchLine>
</joke>
-
<joke category="KnockKnock">
<setUp>
Ammonia
</setUp>
-
<punchLine>
Ammonia little boy and can't reach your door bell
</punchLine>
</joke>
-
<joke category="lightbulb">
<setUp>
hardware engineers
</setUp>
<punchLine>
None. We'll fix it in software.
</punchLine>
</joke>
-
<joke category="crossing">
<setUp>
a giraffe with an echidna
</setUp>
<punchLine>
A seven metre hairbrush
</punchLine>
</joke>
<joke category="crossing">
<setUp>
a sheep with a kanagaroo
</setUp>
<punchLine>
A woolley jumper
</punchLine>
</joke>
<joke category="crossing">
<setUp>
an insomniac, an agnostic, and a dyslexic?
</setUp>
<punchLine>
Someone who stays up all night wondering if there is a Dog.
</punchLine>
</joke>
</jokeList>
XSL:
<xsl:stylesheet version="2.0"
xmlns:xsl=" xmlns="
<xsl:template match="/">
Jokes
<xsl:for-each select="jokeList/joke">
Joke <xsl:value-of select="normalize-space(joke)"/>
<xsl:choose> <xsl:when test="joke/@category='crossing'"></xsl:when> </xsl:choose>What do you get when you cross
<xsl:value-of select="normalize-space(jokes/stuff)"/>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
Current output:
<?xml version="1.0" encoding="UTF-8"?>
Jokes
Joke What do you get when you cross
Joke What do you get when you cross
Joke What do you get when you cross
Joke What do you get when you cross
Joke What do you get when you cross
Joke What do you get when you cross
Joke What do you get when you cross
What I need to do is to select the one category which is the crossing jokes and output them. As you can see it selects the right category and thats it. It seems well formed when asking ruwf.org and compiles when I use a specialed java class file to compile it.
Any hints or suggestions? Iam going nuts about this.
Code follows XML:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE jokeList [
<!ELEMENT jokeList (joke)*>
<!ELEMENT joke (setUp, punchLine)*>
<!ELEMENT setUp (#PCDATA)>
<!ELEMENT punchLine (#PCDATA)>
<!ATTLIST joke category (KnockKnock|lightbulb|crossing) "crossing" >
<!ATTLIST jokes stuff (setUp|punchLine) "setUp" >
]>
<jokeList>
-
<joke category="KnockKnock">
<setUp>
Amos
</setUp>
<punchLine>
A mosquito bit me
</punchLine>
</joke>
-
<joke category="lightbulb">
<setUp>
software engineers
</setUp>
<punchLine>
none, it's a hardware problem
</punchLine>
</joke>
-
<joke category="KnockKnock">
<setUp>
Ammonia
</setUp>
-
<punchLine>
Ammonia little boy and can't reach your door bell
</punchLine>
</joke>
-
<joke category="lightbulb">
<setUp>
hardware engineers
</setUp>
<punchLine>
None. We'll fix it in software.
</punchLine>
</joke>
-
<joke category="crossing">
<setUp>
a giraffe with an echidna
</setUp>
<punchLine>
A seven metre hairbrush
</punchLine>
</joke>
<joke category="crossing">
<setUp>
a sheep with a kanagaroo
</setUp>
<punchLine>
A woolley jumper
</punchLine>
</joke>
<joke category="crossing">
<setUp>
an insomniac, an agnostic, and a dyslexic?
</setUp>
<punchLine>
Someone who stays up all night wondering if there is a Dog.
</punchLine>
</joke>
</jokeList>
XSL:
<xsl:stylesheet version="2.0"
xmlns:xsl=" xmlns="
<xsl:template match="/">
Jokes
<xsl:for-each select="jokeList/joke">
Joke <xsl:value-of select="normalize-space(joke)"/>
<xsl:choose> <xsl:when test="joke/@category='crossing'"></xsl:when> </xsl:choose>What do you get when you cross
<xsl:value-of select="normalize-space(jokes/stuff)"/>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
Current output:
<?xml version="1.0" encoding="UTF-8"?>
Jokes
Joke What do you get when you cross
Joke What do you get when you cross
Joke What do you get when you cross
Joke What do you get when you cross
Joke What do you get when you cross
Joke What do you get when you cross
Joke What do you get when you cross
What I need to do is to select the one category which is the crossing jokes and output them. As you can see it selects the right category and thats it. It seems well formed when asking ruwf.org and compiles when I use a specialed java class file to compile it.
Any hints or suggestions? Iam going nuts about this.