0

This is the XML file we are trying to manipulate:

<?xml version="1.0" encoding="utf-8"?>
<Pois xmlns="urn:schemas-etourist:Poi">
<Poi PID="1234567">
.......
<Kategorien xmlns="urn:schemas-etourist:SchemaExtension>
    <Kategorie xmlns="">
    <Bezeichnung>Museen</Bezeichnung>
    <Ebene>1</Ebene>
    <KategorieID>28</KategorieID>
    <Kategorie xmlns="">
    <Bezeichnung>Galerie</Bezeichnung>
    <Ebene>2</Ebene>
    <KategorieID>225</KategorieID>
    <Kategorie xmlns="">
    <Bezeichnung>Sammlung</Bezeichnung>
    <Ebene>3</Ebene>
    <KategorieID>56</KategorieID>
</Kategorien>
</Poi>
</Pois>

And here is our XSLT:

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" 
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
xmlns:td="urn:schemas-etourist:Poi"
xmlns:td2="urn:schemas-etourist:SchemaExtension"
xmlns:php="http://php.net/xsl"
extension-element-prefixes="php">

<xsl:template match="/td:Pois">
<xsl:apply-templates disable-output-escaping="yes" select="td:Poi/td2:Kategorien/td2:Kategorie[contains(td2:Bezeichnung, 'Museen')]">
<xsl:sort select="td:OBJECT_TEXT_NAME"></xsl:sort>
</xsl:apply-templates>
</xsl:template>

<xsl:template match="td:Poi">
....
</xsl:template>

</xsl:stylesheet>

How do we get the template to select only "Pois" which have a "Kategorie" which contains "Museen"?

Any help would be greatly appreciated!

1
  • Produces an empty result Commented Jul 3, 2013 at 11:28

1 Answer 1

1

td:Poi/td2:Kategorien/td2:Kategorie[contains(td2:Bezeichnung, 'Museen')]

Your elements Kategorie and Bezeichnung are not in a namespace, so you should remove the "td2:" prefixes.

At least, that's what I'm assuming. Your Kategorie elements don't seem to have any end tags, so there's something gone wrong somewhere.

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks Michael. Took us a while to get back to this one. Thanks for the answer. The end tags are complete (our mistake). Removing the td2 from Kategorie and Bezeichnung only outputs '1' & '28', the values for <Ebene> & <KategorieID>. Any more ideas..??
You're still displaying XML that isn't well formed. Are you expecting me to somehow know what the actual XML looks like, when you have shown me something different?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.