Announcement

Collapse
No announcement yet.

XSL in Verbindung mit Amazon WebService

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • XSL in Verbindung mit Amazon WebService

    Guten Tag zusammen,

    ich spiele momentan etwas mit dem AmazonWebservice herum und wollte nun mal die Style-Option testen, über die man zu einer eigenen XSL-Definition verweisen kann, welche dann zur Verarbeitung der XML-Antwort herangezogen wird. Soweit so gut, jedoch funktioniert meine for-each Schleife nicht.

    Hier der Aufbau der XML-Datei:
    Code:
    	−
    	<ItemSearchResponse>
    −
    	<OperationRequest>
    −
    	<HTTPHeaders>
    <Header Name="UserAgent" Value="Mozilla/5.0 (Windows; U; Windows NT 5.1; de; rv:1.8.1.14) Gecko/20080404 Firefox/2.0.0.14"/>
    </HTTPHeaders>
    <RequestId>1A2QMNTTJW9A9AMHTQFC</RequestId>
    −
    	<Arguments>
    <Argument Name="SearchIndex" Value="Books"/>
    <Argument Name="Service" Value="AWSECommerceService"/>
    <Argument Name="Keywords" Value="XSL"/>
    <Argument Name="Operation" Value="ItemSearch"/>
    <Argument Name="AWSAccessKeyId" Value="***************"/>
    </Arguments>
    <RequestProcessingTime>0.101448059082031</RequestProcessingTime>
    </OperationRequest>
    −
    	<Items>
    −
    	<Request>
    <IsValid>True</IsValid>
    −
    	<ItemSearchRequest>
    <Keywords>XSL</Keywords>
    <SearchIndex>Books</SearchIndex>
    </ItemSearchRequest>
    </Request>
    <TotalResults>38</TotalResults>
    <TotalPages>4</TotalPages>
    −
    	<Item>
    <ASIN>3935042914</ASIN>
    −
    	<DetailPageURL>
    http://www.amazon.de/gp/redirect.htm...6DZPASY62Z2DR2
    </DetailPageURL>
    −
    	<ItemAttributes>
    <Author>Tobias Hauser</Author>
    <Creator Role="Autor">Tobias Hauser</Creator>
    <Manufacturer>Entwickler.Press</Manufacturer>
    <ProductGroup>Book</ProductGroup>
    <Title>XML Standards. schnell + kompakt</Title>
    </ItemAttributes>
    </Item>
    .
    .
    .
    Nun habe ich dazu folgende XSL-Definition erstellt:

    Code:
    <?xml version="1.0" ?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://www.w3.org/TR/xhtml1/strict">
    <xsl:template match="/">
    <table border="1">
    <tr><td>ASIN</td>
    <td>URL</td>
    <td>Name</td></tr>
    
    <xsl:for-each select="Items/Item">
    <tr>
     <td><xsl:value-of select="ASIN" /></td>
     <td><xsl:value-of select="DetailPageURL" /></td>
     <td><xsl:value-of select="ItemAttributes/Title" /></td>
    </tr>
    </xsl:for-each>
    
    
    
    </table>
    </xsl:template>
    </xsl:stylesheet>
    jedoch läuft die for-each Schleife wie gesagt nicht durch, sprich ich bekomme eine leere Tabelle gezeigt. Wo liegt mein Fehler?

    Mit freundlichen Grüßen
    Sebastian

  • #2
    Die Referenzierung von xsl:for-each bezieht sich ausgehend vom Wurzelknoten auf /Items/Item. Verwende match="ItemSearchResponse", sofern es das Wurzelelement ist und Items/Item darunter liegt (das zeigt das genannte XML-Dokument nicht deutlich genug).

    Comment


    • #3
      Das verändert mein Problem nun, löst es jedoch nicht ^^ nun kennt er meine Tabelle nicht mehr und gibt mir nur noch alle Daten aneinandergehängt aus:

      Code:
      0A7DQCDY7JP9WCZMT6CY0.0678939819335938TrueXMLBooks19571960321430840http://www.amazon.com/gp/redirect.html%3FASIN=0321430840%26tag=ws%26lcode=xm2%26cID=2025%26ccmID=165953%26location=/XHTML-Sixth-Visual-Quickstart-Guide/dp/0321430840%253FSubscriptionId=15VFHN6DZPASY62Z2DR2Elizabeth CastroPeachpit PressBookHTML, XHTML, and CSS, Sixth Edition (Visual Quickstart Guide)059610197Xhttp://www.amazon.com/gp/redirect.html%3FASIN=059610197X%26tag=ws%26lcode=xm2%26cID=2025%26ccmID=165953%26location=/Head-First-HTML-CSS-XHTML/dp/059610197X%253FSubscriptionId=15VFHN6DZPASY62Z2DR2Eric FreemanElisabeth FreemanO'Reilly Media, Inc.BookHead First HTML with CSS & XHTML059652787Xhttp://www.amazon.com/gp/redirect.html%3FASIN=059652787X%26tag=ws%26lcode=xm2%26cID=2025%26ccmID=165953%26location=/Learning-ActionScript-3-0-Beginners-Guide/dp/059652787X%253FSubscriptionId=15VFHN6DZPASY62Z2DR2Rich ShupeZevan RosserO'Reilly/Adobe Developer LibraryBookLearning ActionScript 3.0: A Beginner's Guide0596529767http://www.amazon.com/gp/redirect.html%3FASIN=0596529767%26tag=ws%26lcode=xm2%26cID=2025%26ccmID=165953%26location=/InDesign-CS3-One-Deke-McClelland/dp/0596529767%253FSubscriptionId=15VFHN6DZPASY62Z2DR2Deke McClellandO'Reilly Media, Inc.BookInDesign CS3 One on One0596514824http://www.amazon.com/gp/redirect.html%3FASIN=0596514824%26tag=ws%26lcode=xm2%26cID=2025%26ccmID=165953%26location=/Head-First-C-Brain-Friendly-Guides/dp/0596514824%253FSubscriptionId=15VFHN6DZPASY62Z2DR2Andrew StellmanJennifer GreeneO'Reilly Media, Inc.BookHead First C# (Brain-Friendly Guides)1933988169http://www.amazon.com/gp/redirect.html%3FASIN=1933988169%26tag=ws%26lcode=xm2%26cID=2025%26ccmID=165953%26location=/LINQ-Action-Fabrice-Marguerie/dp/1933988169%253FSubscriptionId=15VFHN6DZPASY62Z2DR2Fabrice MarguerieSteve EichertJim WooleyMatt WarrenManning PublicationsBookLINQ in Action0596527527http://www.amazon.com/gp/redirect.html%3FASIN=0596527527%26tag=ws%26lcode=xm2%26cID=2025%26ccmID=165953%26location=/Learning-Web-Design-Beginners-StyleSheets/dp/0596527527%253FSubscriptionId=15VFHN6DZPASY62Z2DR2Jennifer Niederst RobbinsAaron GustafsonO'Reilly Media, Inc.BookLearning Web Design: A Beginner's Guide to (X)HTML, StyleSheets, and Web Graphics0596102356http://www.amazon.com/gp/redirect.html%3FASIN=0596102356%26tag=ws%26lcode=xm2%26cID=2025%26ccmID=165953%26location=/Building-Scalable-Web-Sites-applications/dp/0596102356%253FSubscriptionId=15VFHN6DZPASY62Z2DR2Cal HendersonO'Reilly Media, Inc.BookBuilding Scalable Web Sites: Building, scaling, and optimizing the next generation of web applications0596527578http://www.amazon.com/gp/redirect.html%3FASIN=0596527578%26tag=ws%26lcode=xm2%26cID=2025%26ccmID=165953%26location=/3-0-Nutshell-Desktop-Reference-OReilly/dp/0596527578%253FSubscriptionId=15VFHN6DZPASY62Z2DR2Joseph AlbahariBen AlbahariO'Reilly Media, Inc.BookC# 3.0 in a Nutshell: A Desktop Quick Reference (In a Nutshell (O'Reilly))0596514131http://www.amazon.com/gp/redirect.html%3FASIN=0596514131%26tag=ws%26lcode=xm2%26cID=2025%26ccmID=165953%26location=/FileMaker-Pro-9-Missing-Manual/dp/0596514131%253FSubscriptionId=15VFHN6DZPASY62Z2DR2Geoff CoffeySusan ProsserO'Reilly MediaBookFileMaker Pro 9: The Missing Manual
      ich hab im XSL-Code folgendes geändert:

      <xsl:template match="ItemSearchResponse">

      statt

      <xsl:template match="/">

      sonst nichts.

      Ja, ItemSearchResponse ist der oberste Knoten.

      Gruß

      Comment


      • #4
        Ich erhalte mit dem aufgeräumten XML-Code (Textknoten mit Bindestrichen entfernt, Items-Element und ItemSearchResponse-Element geschlossen sowie korrigiertem Namensraum für XHTML):

        HTML Code:
        <?xml version="1.0" encoding="UTF-8"?>
        <table xmlns="http://www.w3.org/1999/xhtml" border="1">
          <tr>
            <td>ASIN</td>
            <td>URL</td>
            <td>Name</td>
          </tr>
          <tr>
            <td>3935042914</td>
            <td>http://www.amazon.de/gp/redirect.htm...6DZPASY62Z2DR2</td>
            <td>XML Standards. schnell + kompakt</td>
          </tr>
        </table>

        Comment


        • #5
          Mmh, dann scheint das Problem mit dem Style-Paramter des Services zusammenhängen. Vielen Dank soweit

          Comment

          Working...
          X