Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2011-09-23
7
Medium Priority
?
363 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
Industry Leaders: 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!

 

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 2000 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

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 …
The Client Need Led Us to RSS I recently had an investment company ask me how they might notify their constituents about their newsworthy publications.  Probably you would think "Facebook" or "Twitter" but this is an interesting client.  Their cons…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

704 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