Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

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

Posted on 2011-09-23
7
Medium Priority
?
365 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
  • 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Create a Windows 10 custom Image with custom task bar and custom start menu using XML for deployment.
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
Kernel Data Recovery is a renowned Data Recovery solution provider which offers wide range of softwares for both enterprise and home users with its cost-effective solutions. Let's have a quick overview of the journey and data recovery tools range he…
Suggested Courses

572 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