[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

Question
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

8.6

XSL issue

Asked by SBennett in Extensible Markup Language (XML)

Tags: valueliteral, valuelist

I have an XSL file that transforms the same data from one XML format to another. I am having trouble with one aspect of it though... If two of the <Attributes ID=""></Attributes>  nodes have the same ID value then I need to present them as one Node in the new format. Pay particular attential to the nodes where id=14.

The logic is that in the old format, if the <Value> node has an id of -6 then there may be a corresponding <Attributes> node (with the same ID value) that contains a <ValueLiteral>  node with a string that, in the new version needs to be placed in the same <Attributes> node instead of having two <Attributes> nodes with the same ID.

Any help Getting this XSL working properly will be greatly appreciated.

Here is my XSL:

--------------------------------------------------------------------------------------------------------------

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" >
<xsl:template match="/">
<Attributes>
<xsl:for-each select="//AttributeSet" >
<AttributeSet>
<xsl:attribute name="id">
<xsl:value-of select="@id" />
</xsl:attribute>
<xsl:for-each select="Attribute" >
<Attribute>
<xsl:attribute name="id">
<xsl:value-of select="@id" />
</xsl:attribute>
<ValueList>
<xsl:for-each select="Value" >
<Value>
<xsl:choose>
<xsl:when test="@id">
<xsl:attribute name="id">
<xsl:value-of select="@id" />
</xsl:attribute>
</xsl:when>
<xsl:otherwise>
<ValueLiteral>
<xsl:value-of select="Name" />
</ValueLiteral>
</xsl:otherwise>
</xsl:choose>
</Value>

</xsl:for-each>
</ValueList>
</Attribute>
</xsl:for-each>
</AttributeSet>
</xsl:for-each>
</Attributes>
</xsl:template>
</xsl:stylesheet>



-----------------------------------------------------------------------------------------------------------

Here is my original XML that I need to apply the XSL to:

--------------------------------------------------------------------------------------------------------------
<?xml version="1.0" encoding="UTF-8" ?>
<SelectedAttributes>
      <AttributeSet id="1951">
            <Attribute id="6">
                  <Value id="31246" />
            </Attribute>
            <Attribute id="31245">
                  <Value id="31253" />
            </Attribute>
            <Attribute id="26446">
                  <Value>
                        <Name>13</Name>
                  </Value>
            </Attribute>
            <Attribute id="14">
                  <Value id="-6" />
            </Attribute>
            <Attribute id="14">
                  <Value>
                        <Name>BRAND NAME</Name>
                  </Value>
            </Attribute>
            <Attribute id="31243">
                  <Value id="31279" />
            </Attribute>
            <Attribute id="10244">
                  <Value id="-10" />
            </Attribute>
      </AttributeSet>
</SelectedAttributes>

---------------------------------------------------------------------------------------------------------------
Here is the output I am currently getting:
---------------------------------------------------------------------------------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<Attributes>
      <AttributeSet id="1951">
            <Attribute id="6">
                  <ValueList>
                        <Value id="31246"/>
                  </ValueList>
            </Attribute>
            <Attribute id="31245">
                  <ValueList>
                        <Value id="31253"/>
                  </ValueList>
            </Attribute>
            <Attribute id="26446">
                  <ValueList>
                        <Value>
                              <ValueLiteral>13</ValueLiteral>
                        </Value>
                  </ValueList>
            </Attribute>
            <Attribute id="14">
                  <ValueList>
                        <Value id="-6"/>
                  </ValueList>
            </Attribute>
            <Attribute id="14">
                  <ValueList>
                        <Value>
                              <ValueLiteral>BRAND NAME</ValueLiteral>
                        </Value>
                  </ValueList>
            </Attribute>
            <Attribute id="31243">
                  <ValueList>
                        <Value id="31279"/>
                  </ValueList>
            </Attribute>
            <Attribute id="10244">
                  <ValueList>
                        <Value id="-10"/>
                  </ValueList>
            </Attribute>
      </AttributeSet>
</Attributes>
---------------------------------------------------------------------------------------------------------------
Here is the output I want:
---------------------------------------------------------------------------------------------------------------
<?xml version="1.0" encoding="UTF-8" ?>
<Attributes>
      <AttributeSet id="1951" categoryId="50604">
            <Attribute id="31245">
                  <ValueList>
                        <Value id="31253" />
                  </ValueList>
            </Attribute>
            <Attribute id="31243">
                  <ValueList>
                        <Value id="31279" />
                  </ValueList>
              </Attribute>
            <Attribute id="10244">
                  <ValueList>
                        <Value id="-10" />
                  </ValueList>
            </Attribute>
            <Attribute id="6">
                  <ValueList>
                        <Value id="31246" />
                  </ValueList>
            </Attribute>
            <Attribute id="26446">
                  <ValueList>
                        <Value id="-3">
                              <ValueLiteral>13</ValueLiteral>
                        </Value>
                  </ValueList>
            </Attribute>
            <Attribute id="14">
                  <ValueList>
                        <Value id="-6">
                              <ValueLiteral>BRAND NAME</ValueLiteral>
                        </Value>
                  </ValueList>
            </Attribute>
      </AttributeSet>
</Attributes>
[+][-]05/14/04 11:20 PM, ID: 11074180Accepted Solution

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

About this solution

Zone: Extensible Markup Language (XML)
Tags: valueliteral, valuelist
Sign Up Now!
Solution Provided By: rdcpro
Participating Experts: 1
Solution Grade: B
 
[+][-]05/14/04 11:07 PM, ID: 11074151Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05/14/04 11:10 PM, ID: 11074156Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05/14/04 11:25 PM, ID: 11074193Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05/17/04 09:39 AM, ID: 11090548Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20091111-EE-VQP-92