Advertisement

07.08.2005 at 07:20AM PDT, ID: 21484858
[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.2

Remove Empty Elements

Asked by SiJP in Extensible Markup Language (XML), Extensible HTML (XHTML)

Tags: , , ,

In theory, I have this XML file (and be gentle, I'm not experienced with XML or XSLT).

<root>
   <data>
      <date>
         <start/>
         <end></end>
      </date>
      <time period="start">12:00</time>
      <time period="end">13:00</time>
   </data>
</root>

As you can see, there are a few elements that have no data.  What I'd like to do is clean up this XML with an XSLT, by getting rid of any elements that have no attributes or values.

Therefore the outputted xml would be:
<root>
   <data>
      <time period="start">12:00</time>
      <time period="end">13:00</time>
   </data>
</root>

Ideally, the <start/> element and <end></end> element would be ripped out.  And because the <date>.. element would subsequently have no child nodes or data, this would go to.

I've had one example given to me (below) but this not only removes all the blank elements, but also the attributes of the elements that do have values.

<xsl:template match="*[not(node())]"/>
<xsl:template match="node()">
  <xsl:copy>
    <xsl:apply-templates select="node()"/>
  </xsl:copy>
</xsl:template>

If this make's sense, how do I remove all empty elements ('simple' and 'complex', I guess) that have no values whatsoever?

Thanks


p.s - sorry about the lacking in points - it's all I have available!Start Free Trial
[+][-]07.08.2005 at 08:46AM PDT, ID: 14398143

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 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.09.2005 at 07:33AM PDT, ID: 14403900

View this solution now by starting your 7-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

Zones: Extensible Markup Language (XML), Extensible HTML (XHTML)
Tags: empty, remove, xml, elements
Sign Up Now!
Solution Provided By: Gertone
Participating Experts: 2
Solution Grade: A
 
 
[+][-]07.09.2005 at 07:41AM PDT, ID: 14403927

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 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.09.2005 at 11:44PM PDT, ID: 14405981

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 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.10.2005 at 07:06AM PDT, ID: 14406877

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 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.11.2005 at 01:17PM PDT, ID: 14415788

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 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.11.2005 at 01:21PM PDT, ID: 14415821

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 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.11.2005 at 01:38PM PDT, ID: 14415970

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 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.11.2005 at 01:41PM PDT, ID: 14415989

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 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.11.2005 at 03:07PM PDT, ID: 14416887

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 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.12.2005 at 01:36AM PDT, ID: 14419521

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 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.12.2005 at 07:46AM PDT, ID: 14421949

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 7-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32