I'm trying to output a category tree/sitemap to HTML using XML & XSLT. The XML gives me a list of categories and the current selected category in two different nodes. I need to grab the category node from the tree that corresponds to selected category. Here's a sample XML:
I can rock it with an xpath that looks like:
but what I really need is:
however, that just ends up matching everything. Anybody know why? Thank you, thank you!
Code:
<Page>
<CategoryTree>
<CurrentCategoryID>0</CurrentCategoryID>
<Categories>
<CategoryID>0</CategoryID>
<CategoryName>__parent</CategoryName>
<ChildCategories>
<Category>
<CategoryID>31</CategoryID>
<CategoryName>My Category</CategoryName>
<ChildCategories>
<Category>
<CategoryID>39</CategoryID>
<CategoryName>Child 1</CategoryName>
<ChildCategories />
</Category>
<Category>
<CategoryID>42</CategoryID>
<CategoryName>Child2</CategoryName>
<ChildCategories />
</Category>
</ChildCategories>
</Category>
</ChildCategories>
</Categories>
</CategoryTree>
<BrowseCurrentCategory>
<CategoryID>31</CategoryID>
</BrowseCurrentCategory>
</Page>
I can rock it with an xpath that looks like:
Code:
/Page/CategoryTree//[CategoryID=31]
but what I really need is:
Code:
/Page/CategoryTree//[CategoryID=/Page/BrowseCurrentCategory/CategoryID]