0

I'm trying to do some transformation. So far everything look correct, but XSLT cannot get value one of the nodes (@Curl) meanwhile another node (@Name) value getting correct. Heres is XSLT:

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl"
>
  <xsl:output method="xml" indent="yes"/>
  <xsl:template match="/">
    <xsl:for-each select="Menu/Category">
      <h3>
        <i class="icon-cube"></i>
        <xsl:value-of select="MainCategory/@Name"/>
      </h3>
      <ul class="listview fluid">
        <xsl:for-each select="MainCategory/SubCategory">
          <li>
            <xsl:element name="a">
              <xsl:attribute name="href">
                <xsl:value-of select="@CUrl"/>
              </xsl:attribute>
              <xsl:value-of select="@Name"/>
            </xsl:element>
          </li>
        </xsl:for-each>
      </ul>
    </xsl:for-each>
  </xsl:template>
</xsl:stylesheet>

And XML is here:

<?xml version="1.0" encoding="utf-8"?>
<Menu>
  <Category>
    <MainCategory Name="Транспорт"></MainCategory>
  </Category>
  <Category>
    <MainCategory Name="Недвижимость">
      <SubCategory CURL="http://shop.bubaport.ru/category/1" Name="Продажа"></SubCategory>
      <SubCategory CURL="http://shop.bubaport.ru/category/2" Name="Покупка"></SubCategory>
      <SubCategory CURL="http://shop.bubaport.ru/category/3" Name="Аренда"></SubCategory>
    </MainCategory>
  </Category>

2 Answers 2

3

Attribute names are case-sensitive. In your XML, you have:

<SubCategory CURL="http://shop.bubaport.ru/category/1" Name="Продажа">

But in your XSL, you wrote:

<xsl:value-of select="@CUrl"/>

Try changing that to:

<xsl:value-of select="@CURL"/>
Sign up to request clarification or add additional context in comments.

Comments

0

XML is case sensitive. The attribute name mentioned in the XSL is not matching with the XML. Try with the below line.

<xsl:value-of select="@CURL"/>

Regards,

Comments

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.