Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

XML Schema validierung

Empfohlene Antworten

Veröffentlicht

Hallo,

Ich habe folgendes Problem ich habe ein XML-Schema:


<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">


	<xsd:element name="project" type="projectType">

	  <xsd:complexType name="projectType">

		<xsd:sequence>

			<xsd:element name="package" type="packageType" maxOccurs="unbounded"

				minOccurs="1">

			</xsd:element>

		</xsd:sequence>

		<xsd:attributeGroup ref="nameAttr"></xsd:attributeGroup>

 	  </xsd:complexType>

 	</xsd:element>


	<xsd:complexType name="packageType">

		<xsd:sequence>

			<xsd:element name="class" type="classType" maxOccurs="1"

				minOccurs="1">

			</xsd:element>

		</xsd:sequence>

		<xsd:attributeGroup ref="nameAttr"></xsd:attributeGroup>

	</xsd:complexType>


	<xsd:complexType name="classType">

		<xsd:sequence>

			<xsd:element name="method" type="methodType" maxOccurs="unbounded" minOccurs="1"></xsd:element>

		</xsd:sequence>

		<xsd:attributeGroup ref="nameAttr"></xsd:attributeGroup>

	</xsd:complexType>


    <xsd:complexType name="methodType">

		<xsd:sequence>

			<xsd:element name="param" type="paramType" maxOccurs="unbounded" minOccurs="0"></xsd:element>

		</xsd:sequence>

    	<xsd:attributeGroup ref="nameAttr"></xsd:attributeGroup>

    </xsd:complexType>


    <xsd:complexType name="paramType">

		<xsd:sequence>

			<xsd:element name="subparam" type="subparamType" maxOccurs="unbounded" minOccurs="0"></xsd:element>

		</xsd:sequence>

    	<xsd:attributeGroup ref="nameAttr"></xsd:attributeGroup>

    	<xsd:attributeGroup ref="paramAttr"></xsd:attributeGroup>   

    </xsd:complexType>


    <xsd:complexType name="subparamType">

    	<xsd:sequence>

    		<xsd:element name="subparam" type="subparamType" maxOccurs="unbounded" minOccurs="0"></xsd:element>

    	</xsd:sequence>

    	<xsd:attributeGroup ref="nameAttr"></xsd:attributeGroup>

    	<xsd:attributeGroup ref="paramAttr"></xsd:attributeGroup>

    </xsd:complexType>


    <xsd:attributeGroup name="nameAttr">

    	<xsd:attribute name="name" use="required" type="xsd:string"></xsd:attribute>

    </xsd:attributeGroup>


    <xsd:attributeGroup name="paramAttr">

		<xsd:attribute  name="type" use="required" type="xsd:string"></xsd:attribute>    	

		<xsd:attribute  name="nullable" use="required" type="xsd:boolean"></xsd:attribute>     

    </xsd:attributeGroup>

</xsd:schema>

Und ein XML-Dokument welches auf dieses Schema verweist:

<val:project xmlns:val="validationSchema.xsd" name="comuga">

	<val:class>

	</val:class>

	<val:package name="com.XXX.comugaservice.business.delegate.hibernate">

		<val:class>

		</val:class>

		<val:class name="BdHibernate">

			<val:method name="ablehnenUrlaub">

				<val:param name="urlaubsID" nullable="true" type="int" />

				<val:param name="userComsi" nullable="false" type="java.lang.String" />

			</val:method>

			<val:method name="ablehnenWechselnOrganisation">

				<val:param name="comsiMitarbeiter" nullable="false"	type="java.lang.String" />

				<val:param name="comsiBenutzer" nullable="false" type="java.lang.String" />

			</val:method>

			<val:method name="anzeigenUrlaub">

[…]

Nun folgendes Problem: Wenn ich dieses XML-Dokument mittels Dom4J validieren (möchte) geht das Dokument glatt durch, obwohl (zu Testzwecken) das Class-Element im package nur einmal vorhanden sein darf bzw. NUR im package vorhanden sein darf, ausserdem sollte das Attribut "name" required sein! Woran kann der Fehler (dass kein Fehler auftritt) liegen oder wie kann ich mein XML-Dokument ordentlich validieren?

Eigentlich soll jedes Element ausschliesslich in seiner "Ebene" existieren.

Ich habe mir Thema XML-Schema in den letzten beiden Tagen versucht anzueignen, daher wäre ich dankbar für jeden verbesserungsvorschlag, zu dem Schema.

Danke und Gruss

at sich erledigt, ich habe das Schema noch nicht korrekt eingebunden:


<project xmlns:val="validationSchema.xsd" 

    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

    xsi:noNamespaceSchemaLocation="Z:\COMUGA\PPP\comuga-service\web\src\main\resources\validationSchemaNeu.xsd">

Mit dem XML Copy Editor und einem Schema-Validierer aus dem Netz bin ich sehr weit gekommen.

Archiv

Dieses Thema wurde archiviert und kann nicht mehr beantwortet werden.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.