Solved

how to ignore certain entries in an xml using xslt1.0

Posted on 2011-09-23
7
355 Views
Last Modified: 2012-05-12
My xml is attached. I want all the entries of dc:creator except where the value is "SpringerLink (Online service)"

I have tried something like this but it does not seem to work

<xsl:for-each select="dc:creator">
                                    <mauthorpersons>
                                    
                                    <xsl:if test="[dc:creator!='SpringerLink (Online service)']">
                                                <xsl:value-of select="."/>
                                          </xsl:if>
                                                                        
                                    </mauthorpersons>
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <rdf:Description>
    <dc:title>Light Scattering Reviews 4 Single Light Scattering and Radiative Transfer </dc:title>
    <dc:creator>Kokhanovsky, Alexander A.</dc:creator>
    <dc:creator>SpringerLink (Online service)</dc:creator>
    <dc:type>software, multimedia</dc:type>
    <dc:publisher>Springer Berlin Heidelberg</dc:publisher>
    <dc:date>2009</dc:date>
    <dc:publicationplace>Berlin, Heidelberg </dc:publicationplace>
    <dc:language>eng</dc:language>
    <dc:subject>Geography</dc:subject>
    <dc:subject>Meteorology</dc:subject>
    <dc:subject>Remote sensing</dc:subject>
    <dc:subject>Weights and measures</dc:subject>
    <dc:subject>Earth Sciences</dc:subject>
    <dc:subject>Meteorology/Climatology</dc:subject>
    <dc:subject>Remote Sensing/Photogrammetry</dc:subject>
    <dc:subject>Measurement Science, Instrumentation</dc:subject>
    <dc:relation>Springer eBooks</dc:relation>
    <dc:identifier>http://dx.doi.org/10.1007/978-3-540-74276-0</dc:identifier>
    <dc:identifier_isbn></dc:identifier_isbn>
    <dc:identifier_dbid>http://dx.doi.org/10.1007/978-3-540-74276-0</dc:identifier_dbid>
  </rdf:Description>
  <rdf:Description>
    <dc:title>iNetSec 2009 – Open Research Problems in Network Security IFIP WG 11.4 International Workshop, Zurich, Switzerland, April 23-24, 2009, Revised Selected Papers </dc:title>
    <dc:creator>Camenisch, Jan.</dc:creator>
    <dc:creator>Kesdogan, Dogan.</dc:creator>
    <dc:creator>SpringerLink (Online service)</dc:creator>
    <dc:type>software, multimedia</dc:type>
    <dc:publisher>Springer-Verlag Berlin Heidelberg</dc:publisher>
    <dc:date>2009</dc:date>
    <dc:publicationplace>Berlin, Heidelberg </dc:publicationplace>
    <dc:language>eng</dc:language>
    <dc:subject>Computer science</dc:subject>
    <dc:subject>Computer Communication Networks</dc:subject>
    <dc:subject>Data protection</dc:subject>
    <dc:subject>Data encryption (Computer science)</dc:subject>
    <dc:subject>Information Systems</dc:subject>
    <dc:subject>Computer Science</dc:subject>
    <dc:subject>Systems and Data Security</dc:subject>
    <dc:subject>Data Encryption</dc:subject>
    <dc:subject>Management of Computing and Information Systems</dc:subject>
    <dc:subject>Computer Communication Networks</dc:subject>
    <dc:subject>Computers and Society</dc:subject>
    <dc:relation>Springer eBooks</dc:relation>
    <dc:identifier>http://dx.doi.org/10.1007/978-3-642-05437-2</dc:identifier>
    <dc:identifier_isbn></dc:identifier_isbn>
    <dc:identifier_dbid>http://dx.doi.org/10.1007/978-3-642-05437-2</dc:identifier_dbid>
  </rdf:Description>
  <rdf:Description>
    <dc:title>Multiscale, Nonlinear and Adaptive Approximation Dedicated to Wolfgang Dahmen on the Occasion of his 60th Birthday </dc:title>
    <dc:creator>DeVore, Ronald .</dc:creator>
    <dc:creator>Kunoth, Angela.</dc:creator>
    <dc:creator>SpringerLink (Online service)</dc:creator>
    <dc:type>software, multimedia</dc:type>
    <dc:publisher>Springer-Verlag Berlin Heidelberg</dc:publisher>
    <dc:date>2009</dc:date>
    <dc:publicationplace>Berlin, Heidelberg </dc:publicationplace>
    <dc:language>eng</dc:language>
    <dc:subject>Mathematics</dc:subject>
    <dc:subject>Electronic data processing</dc:subject>
    <dc:subject>Computer science</dc:subject>
    <dc:subject>Numerical analysis</dc:subject>
    <dc:subject>Engineering mathematics</dc:subject>
    <dc:subject>Mathematics</dc:subject>
    <dc:subject>Computational Mathematics and Numerical Analysis</dc:subject>
    <dc:subject>Numerical Analysis</dc:subject>
    <dc:subject>Numeric Computing</dc:subject>
    <dc:subject>Appl.Mathematics/Computational Methods of Engineering</dc:subject>
    <dc:relation>Springer eBooks</dc:relation>
    <dc:identifier>http://dx.doi.org/10.1007/978-3-642-03413-8</dc:identifier>
    <dc:identifier_isbn></dc:identifier_isbn>
    <dc:identifier_dbid>http://dx.doi.org/10.1007/978-3-642-03413-8</dc:identifier_dbid>
  </rdf:Description>
  <rdf:Description>
    <dc:title>Relativistic Methods for Chemists</dc:title>
    <dc:creator>Barysz, Maria.</dc:creator>
    <dc:creator>Ishikawa, Yasuyuki.</dc:creator>
    <dc:creator>SpringerLink (Online service)</dc:creator>
    <dc:type>software, multimedia</dc:type>
    <dc:publisher>Springer Science+Business Media B.V.</dc:publisher>
    <dc:date>2010</dc:date>
    <dc:publicationplace>Dordrecht </dc:publicationplace>
    <dc:language>eng</dc:language>
    <dc:subject>Chemistry</dc:subject>
    <dc:subject>Chemistry, inorganic</dc:subject>
    <dc:subject>Chemistry, Physical organic</dc:subject>
    <dc:subject>Materials</dc:subject>
    <dc:subject>Chemistry</dc:subject>
    <dc:subject>Theoretical and Computational Chemistry</dc:subject>
    <dc:subject>Physical Chemistry</dc:subject>
    <dc:subject>Materials Science, general</dc:subject>
    <dc:subject>Inorganic Chemistry</dc:subject>
    <dc:relation>Springer eBooks</dc:relation>
    <dc:identifier>http://dx.doi.org/10.1007/978-1-4020-9975-5</dc:identifier>
    <dc:identifier_isbn></dc:identifier_isbn>
    <dc:identifier_dbid>http://dx.doi.org/10.1007/978-1-4020-9975-5</dc:identifier_dbid>
  </rdf:Description>
  <rdf:Description>
    <dc:title>Photocatalytic Reaction Engineering</dc:title>
    <dc:creator>Lasa, Hugo.</dc:creator>
    <dc:creator>Serrano, Benito.</dc:creator>
    <dc:creator>Salaices, Miguel.</dc:creator>
    <dc:creator>SpringerLink (Online service)</dc:creator>
    <dc:type>software, multimedia</dc:type>
    <dc:publisher>Springer Science+Business Media LLC</dc:publisher>
    <dc:date>2005</dc:date>
    <dc:publicationplace>Boston, MA </dc:publicationplace>
    <dc:language>eng</dc:language>
    <dc:subject>Chemistry</dc:subject>
    <dc:subject>Chemical engineering</dc:subject>
    <dc:subject>Environmental protection</dc:subject>
    <dc:subject>Environmental pollution</dc:subject>
    <dc:subject>Chemistry</dc:subject>
    <dc:subject>Industrial Chemistry/Chemical Engineering</dc:subject>
    <dc:subject>Atmospheric Protection/Air Quality Control/Air Pollution</dc:subject>
    <dc:subject>Waste Water Technology / Water Pollution Control / Water Management / Aquatic Pollution</dc:subject>
    <dc:relation>Springer eBooks</dc:relation>
    <dc:identifier>http://dx.doi.org/10.1007/0-387-27591-6</dc:identifier>
    <dc:identifier_isbn></dc:identifier_isbn>
    <dc:identifier_dbid>http://dx.doi.org/10.1007/0-387-27591-6</dc:identifier_dbid>
  </rdf:Description>
  <rdf:Description>

</rdf:RDF>

Open in new window

0
Comment
Question by:mmalik15
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
7 Comments
 
LVL 60

Expert Comment

by:Geert Bormans
ID: 36588571
the problem is "context"
in a for-each you move to the context of the node you are visiting

                                    <xsl:if test="[. !='SpringerLink (Online service)']">
will work

I would do                                     <xsl:if test="[not( normalize-space(.) ='SpringerLink (Online service)' )]">
to be on teh safe side
0
 

Author Comment

by:mmalik15
ID: 36590037
thanks for the comment Gertone but i m getting Invalid Token error with both the options above.

Thats how i m trying it now

<xsl:for-each select="dc:creator">
                                    <mauthorpersons>
                                          <xsl:if test="[.!='SpringerLink (Online service)']">
                                                <xsl:value-of select="."/>
                                          </xsl:if>
                                    </mauthorpersons>
                                    <!-- END of mauthorpersons -->
                              </xsl:for-each>


or

<xsl:for-each select="dc:creator">
                                    <mauthorpersons>
                                          <xsl:if test="[not( normalize-space(.) ='SpringerLink (Online service)' )]">
                                                <xsl:value-of select="."/>
                                          </xsl:if>
                                    </mauthorpersons>
                                    <!-- END of mauthorpersons -->
                              </xsl:for-each>

0
 
LVL 60

Expert Comment

by:Geert Bormans
ID: 36590469
sorry, you don't need the [], it is a boolean expression, not a predicate
   <xsl:if test="not( normalize-space(.) ='SpringerLink (Online service)' )">

sorry about that, I copied from your xsl:if, but did not change enough
0
Resolve Critical IT Incidents Fast

If your data, services or processes become compromised, your organization can suffer damage in just minutes and how fast you communicate during a major IT incident is everything. Learn how to immediately identify incidents & best practices to resolve them quickly and effectively.

 

Author Comment

by:mmalik15
ID: 36590495
I manage to correct the syntax as you mentioned. But the problem what i m having now is i am getting results like this  

<dc:creator>Kokhanovsky, Alexander A.</dc:creator>
 <dc:creator>SpringerLink (Online service)</dc:creator>

Result
<mauthorpersons>Kokhanovsky, Alexander A.</mauthorpersons>
            <mauthorpersons/>


Second Result

<dc:creator>Camenisch, Jan.</dc:creator>
    <dc:creator>Kesdogan, Dogan.</dc:creator>
    <dc:creator>SpringerLink (Online service)</dc:creator>


<mauthorpersons>Camenisch, Jan.</mauthorpersons>
            <mauthorpersons>Kesdogan, Dogan.</mauthorpersons>
            <mauthorpersons/>


I dont want the last tag i.e. <mauthorpersons/>
0
 
LVL 60

Accepted Solution

by:
Geert Bormans earned 500 total points
ID: 36591515
ah, I thought that is what you wanted
you iterate over all nodes and then you create content with a particular condition
If you don't need the empty nodes, be selective in your iteration

<xsl:for-each select="dc:creator[not( normalize-space(.) ='SpringerLink (Online service)' )]">

and drop the if test
0
 

Author Closing Comment

by:mmalik15
ID: 36591906
Perfect buddy!
0
 
LVL 60

Expert Comment

by:Geert Bormans
ID: 36591914
welcome
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The Problem How to write an Xquery that works like a SQL outer join, providing placeholders for absent data on the outer side?  I give a bit more background at the end. The situation expressed as relational data Let’s work through this.  I’ve …
Introduction In my previous article (http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SSIS/A_9150-Loading-XML-Using-SSIS.html) I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

735 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question