tutorials.de Buch-Aktion 05/2012
ERLEDIGT
NEIN
ANTWORTEN
0
ZUGRIFFE
1178
EMPFEHLEN
  • An Twitter übertragen
  • An Facebook übertragen
AUF DIESES THEMA
ANTWORTEN
  1. #1
    jazzhunter jazzhunter ist offline Rookie
    Registriert seit
    Jul 2011
    Beiträge
    7
    Hallo,

    ich habe folgendes XML-Schema, dass ich per XSLT parsen möchte

    Code :
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    
    <?xml version="1.0" encoding="UTF-8"?>
    <schema xmlns="http://www.w3.org/2001/XMLSchema"
        xmlns:xlink="http://www.w3.org/1999/xlink"
        xmlns:gml="http://www.opengis.net/gml/3.2"
        version="3.2.1" elementFormDefault="qualified" targetNamespace="http://www.opengis.net/gml/3.2">
        <annotation>
            <documentation>GML 3.2.1 profile for NAS version 6.0_B</documentation>
        </annotation>
        <import schemaLocation="../xlink/1.0.0/xlinks.xsd" namespace="http://www.w3.org/1999/xlink"/>
        <!-- ================================================= -->
        <complexType name="AbstractMetadataPropertyType" abstract="true">
            <sequence/>
            <attributeGroup ref="gml:OwnershipAttributeGroup"/>
        </complexType>
        <!-- ================================================= -->
        <attributeGroup name="OwnershipAttributeGroup">
            <attribute name="owns" type="boolean" default="false"/>
        </attributeGroup>
        <!-- ================================================= -->
        <complexType name="AbstractMemberType" abstract="true">
            <sequence/>
            <attributeGroup ref="gml:OwnershipAttributeGroup"/>
        </complexType>
        <!-- ================================================= -->
        <complexType name="CodeType">
            <simpleContent>
                <extension base="string">
                    <attribute name="codeSpace" type="anyURI"/>
                </extension>
            </simpleContent>
        </complexType>
        <!-- ================================================= -->
        <element name="AbstractFeature" type="gml:AbstractFeatureType" abstract="true"
            substitutionGroup="gml:AbstractGML"> </element>
    </schema>

    Nun das XSLT-File um den Namen der Elemente abzufragen

    Code :
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    
    <?xml version="1.0" encoding="UTF-8" ?>
    <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:gml="http://www.opengis.net/gml/3.2" xmlns:xs="http://www.w3.org/2001/XMLSchema">
    <xsl:output method="text" encoding="UTF-8" indent="no" />
    <xsl:strip-space elements="*"/>
     
    <xsl:variable name="tab"><xsl:text> </xsl:text></xsl:variable>
     <xsl:variable name="newline"><xsl:text>&#xa;</xsl:text></xsl:variable>
     
    <xsl:template match="//xs:element[parent::xs:schema]">
        <xsl:value-of select="$newline"/>
        Elementname: <xsl:value-of select="@name"/>
        <xsl:value-of select="$newline"/>
    </xsl:template>
           
    </xsl:stylesheet>

    Seltsamer Weise wird nicht nur der Elementname AbstractFeature zurück gegeben, sondern auch der annotation><documentation> Block, obwohl dieser nicht abgefragt wird (vgl. match="//xs:element[parent::xs:schema]").

    Somit wird folgende Ausgabe erzeugt:

    GML 3.2.1 profile for NAS version 6.0_B

    Elementname: AbstractFeature


    erwartet habe ich aber:

    Elementname: AbstractFeature

    Wie kommt das zu Stande und wie könnte man die Ausgabe "GML 3.2.1 profile for NAS version 6.0_B" unterdrücken?

    für eure Hilfe wäre ich sehr dankbar
    Geändert von jazzhunter (14.07.11 um 18:31 Uhr)
     

Ähnliche Themen

  1. Antworten: 3
    Letzter Beitrag: 02.03.10, 11:00
  2. xml mittels xslt aus bestehenden xml erzeugen
    Von chris_head im Forum XML Technologien
    Antworten: 0
    Letzter Beitrag: 12.01.10, 12:17
  3. XML mittels XSLT in Java Properties umwandeln
    Von Fenrizwolf im Forum XML Technologien
    Antworten: 6
    Letzter Beitrag: 23.10.09, 18:55
  4. mittels XSLT in mehrere Zieldateien?
    Von UkAtZ im Forum XML Technologien
    Antworten: 0
    Letzter Beitrag: 26.08.08, 15:17
  5. Probleme PHP/XML Parsen mittels Cronjob
    Von spamcam im Forum PHP
    Antworten: 0
    Letzter Beitrag: 29.03.05, 15:13