Announcement

Collapse
No announcement yet.

XSLT for-each Abfrage

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

  • XSLT for-each Abfrage

    Hallo Zusammen,

    ich habe folgende XML-Struktur:

    Code:
    <GKStandardComments>
      <GKStandardComment>
         <GKStandardComment_Attribute name="Description">
            <name>i18N(Description)</name>
            <value>Dies ist eine Beschreibung</value>
         </GKStandardComment_Attribute>
         <GKStandardComment_Attribute name="Category">
            <name>i18N(Kategorie)</name>
            <value>Kategorie 1</value>
         </GKStandardComment_Attribute>
         <GKStandardComment_Attribute name="GKBezeichnung">
            <name>i18N(BezeichnungDE)</name>
            <value>Eine weitere Bezeichnung</value>
         </GKStandardComment_Attribute>
      </GKStandardComment>
      <GKStandardComment>
         <GKStandardComment_Attribute name="Description">
            <name>i18N(Description)</name>
            <value>Beschreibung einer Tatsache</value>
         </GKStandardComment_Attribute>
         <GKStandardComment_Attribute name="Category">
            <name>i18N(Kategorie)</name>
            <value>Kategorie 4</value>
         </GKStandardComment_Attribute>
         <GKStandardComment_Attribute name="GKBezeichnung">
            <name>i18N(BezeichnungDE)</name>
            <value>Noch eine Bezeichnung</value>
         </GKStandardComment_Attribute>
      </GKStandardComment>
      <GKStandardComment>
       ...
      </GKStandardComment>
    </GKStandardComments>
    Jetzt möchte ich in einer for-each mit jeweils den Tag <value> und <name> eines jeden GK_StandardComment_Attribute anzeigen. Ich weiß nur nicht, wie ich über den Key darauf zugreifen kann. Er erscheint kein Fehler, nur leere Zeilen.
    Folgendes habe ich schon probiert:

    Code:
    <xsl:for-each select="GKStandardComments/GKStandardComment">
      <fo:block>
        <xsl:value-of select="GKStandardComment_Attribute[@key = 'Description']/value"/>
      </fo:block>
    bzw.
    Code:
    <xsl:for-each select="GKStandardComments/GKStandardComment">
      <fo:block>
        <xsl:value-of select="GKStandardComment_Attribute[@name = 'Description']/value"/>
      </fo:block>
    Kann mir da einer auf die Sprünge helfen?

    Vielen Dank :-)

  • #2
    Code:
    GKStandardComment_Attribute[@key = 'Description']
    macht bei deinem XML keinen Sinn, denn Attribute mit Namen "key" sehe ich da nicht.
    Das zweite Beispiel sieht korrekt aus, wenn es dabei keine Ausgabe gibt, ist der häufigste Grund die Benutzung von Namensräumen im XML, die du aber nicht gezeigt hast. Prüfe also, ob es irgendwelche
    Code:
    xmlns="..."
    im XML gibt. So es welche gibt und du Hilfe mit dem XSLT brauchst, erkläre bitte, ob du XSLT 1.0 oder 2.0 verwendest, und poste natürlich ein XML-Eingabedokument mit allen verwendeten Namensraumdeklarationen.

    Comment


    • #3
      Hallo,

      danke, also ich verwende XSLT1.0
      Die einzigen 2 xmlns Attribute befinden sich am Anfang des Stylesheets. Der sieht so hier aus:

      Code:
      <?xml version="1.0" encoding="ISO-8859-1"?>
      <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format">
      ...
      Das XML Eingabedokument beginnt so hier:
      Code:
      <?xml version="1.0" encoding="UTF-8"?>
      <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
      <fo:layout-master-set>
      <fo:simple-page-master margin-right="0.4cm" margin-left="0.4cm" margin-bottom="0cm" margin-top="0.4cm" master-name="only-page" page-width="29.7cm" page-height="21cm"><fo:region-body margin-bottom="1.5cm" margin-top="3.5cm"/>...
      Ich sehe gerade, das Encoding ist ein anderer Zeichensatz, sollte abe rnicht stören, oder?

      Comment


      • #4
        Im ersten Posting hat das Eingabdokument Elemente wie "GKStandardComment", jetzt "fo:root". Das macht keinen Sinn. Ich will wissen, ob es im Dokument mit den "GKStandardComment"-Elementen irgendwelche xmlns="..." Deklarationen gibt.

        Comment

        Working...
        X