Hello all
I need your help wiht XPath Axes in XSL for any XML. So that the XSL is valid against any XML.
I tried with ancestor-or-self::* and stuff like that but I think I dont really understand what it is all about.
For example I want to visualize following XML with an XSL that is valid for any XML:
<adressbuch>
<eintrag nr="1">
<name>Bernd Pack</name>
<adresse>Clausengasse 12</adresse>
<ort>1090 Wien</ort>
<email>bp@gmx.at</email>
<telefon>0650</telefon>
<geburtstag>12.12.1982</geburtstag>
</eintrag>
<eintrag nr="2">
<name>Patricia Bauer</name>
<adresse>Pflanzsteig 16</adresse>
<ort>1090 Wien</ort>
<email>pb@aon.at</email>
<telefon>06602</telefon>
<geburtstag>01.03.1957</geburtstag>
</eintrag>
</adressbuch>
So now I need a XSL which visualizes my XML above (and any other XML). For example every "eintrag" should be visualized with number1.jpg and any child -> "name" til "geburtstag" shall be visualized with number2.jpg. How shall i do that?
I know how to do it, when I know the tag-name but I dont know them in that case because it shall be valid for any XML.
So I tried the following XSL which does not really work:
<xsl:template match="/">
<xsl:element name="root">
<xsl:call-template name="visual"/>
</xsl:element>
</xsl:template>
<xsl:template name="visual">
<xsl:for-each select="//*">
<xsl:sort select="ancestor-or-self::*" order="descending"/>
<xsl:if test="position()=1">
<xsl:value-of select="ancestor-or-self::*"/>
</xsl:if>
</xsl:for-each>
</xsl:template>
I know I need to paste some choose and whens in I think to choose which jpg should be selected but my main problem is that the XPathes dont work, or better I dont understand them. Could somebody please help me???
Thanks a lot
sibl
I need your help wiht XPath Axes in XSL for any XML. So that the XSL is valid against any XML.
I tried with ancestor-or-self::* and stuff like that but I think I dont really understand what it is all about.
For example I want to visualize following XML with an XSL that is valid for any XML:
<adressbuch>
<eintrag nr="1">
<name>Bernd Pack</name>
<adresse>Clausengasse 12</adresse>
<ort>1090 Wien</ort>
<email>bp@gmx.at</email>
<telefon>0650</telefon>
<geburtstag>12.12.1982</geburtstag>
</eintrag>
<eintrag nr="2">
<name>Patricia Bauer</name>
<adresse>Pflanzsteig 16</adresse>
<ort>1090 Wien</ort>
<email>pb@aon.at</email>
<telefon>06602</telefon>
<geburtstag>01.03.1957</geburtstag>
</eintrag>
</adressbuch>
So now I need a XSL which visualizes my XML above (and any other XML). For example every "eintrag" should be visualized with number1.jpg and any child -> "name" til "geburtstag" shall be visualized with number2.jpg. How shall i do that?
I know how to do it, when I know the tag-name but I dont know them in that case because it shall be valid for any XML.
So I tried the following XSL which does not really work:
<xsl:template match="/">
<xsl:element name="root">
<xsl:call-template name="visual"/>
</xsl:element>
</xsl:template>
<xsl:template name="visual">
<xsl:for-each select="//*">
<xsl:sort select="ancestor-or-self::*" order="descending"/>
<xsl:if test="position()=1">
<xsl:value-of select="ancestor-or-self::*"/>
</xsl:if>
</xsl:for-each>
</xsl:template>
I know I need to paste some choose and whens in I think to choose which jpg should be selected but my main problem is that the XPathes dont work, or better I dont understand them. Could somebody please help me???
Thanks a lot
sibl