Hallo,
Wenn ich hiermit die ID mit ausgebe, bekomme ich leider weiterhin die falsche id.
<xsl:template match="Page[not(@id)]">
<xsl:value-of select="concat(@name,' ',descendant-or-self::Page/@id)"/>
Wenn du nachdenkst, siehst du selbst das das relativ unsinnig ist:
-or-self greift so oder so nicht, da das Template Pages ohne id abarbeitet.
descendat liefert deshalb die falsch ID, weil es Pages im document-order (also so wie sie im Quelltext stehen) durchsucht und davon das erste treffende nimmt.
Ergebnis:
Niederlassungen 1
Bei "niederlassungen" brauche ich aber die ID 8 für "Enschede".
Folgendes sollte dir das Gewüschte ausgeben:
<xsl:template match="PageHierarchy">
<xsl:for-each select="Page[not(@id) and Page[not(@id)]]">
<xsl:sort select="@priority" />
<xsl:variable name="subpageid">
<xsl:for-each select="Page[not(@id)]">
<xsl:sort select="@priority" />
<xsl:if test="position()= 1">
<xsl:for-each select="Page[@id]">
<xsl:sort select="@priority" />
<xsl:if test="position()= 1">
<xsl:value-of select="@id" />
</xsl:if>
</xsl:for-each>
</xsl:if>
</xsl:for-each>
</xsl:variable>
<div>
<xsl:value-of select="concat(@name, ' ', $subpageid)"/>
xsl:apply-templates
<xsl:sort select="@priority" />
</xsl:apply-templates>
</div>
<br />
</xsl:for-each>
</xsl:template>
<xsl:template match="Page[not(@id) and Page[@id]]">
<xsl:variable name="subpageid">
<xsl:for-each select="Page[@id]">
<xsl:sort select="@priority" />
<xsl:if test="position()= 1">
<xsl:value-of select="@id" />
</xsl:if>
</xsl:for-each>
</xsl:variable>
<div style="text-indent:25px;">
<xsl:value-of select="concat(@name, ' ', $subpageid)"/>
xsl:apply-templates
<xsl:sort select="@priority" />
</xsl:apply-templates>
</div>
</xsl:template>
<xsl:template match="Page[@id]">
<div style="text-indent:50px;">
<xsl:value-of select="concat(@name,' ',@id)"/>
</div>
</xsl:template>
Grüße
Thomas