473,385 Members | 1,764 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

XML-Schema, which only declares an Attribute and no elements?

Hello

I have the following problem: I want to have an XML-Schema that only
declares one Attribute, but does not specify in which specific Element it
has to be used. I've already tried the following:

------- agnes.xsd --------------------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schematargetNamespace="http://agnes.sf.net/ns/agnes"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified" xmlns="http://agnes.sf.net/ns/agnes">
<xsd:complexType name="agnesType">
<xsd:attribute name="id" type="idType"/>
</xsd:complexType>
<xsd:simpleType name="idType">
<xsd:restriction base="xsd:token">
<xsd:pattern value="AGID_[0-9a-zA-Z]{16}"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:schema>
------- agnes.xsd --------------------------------------------------
The intented use of this Schema would be:

------- whatever.xsd -----------------------------------------------
<whatever xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:agnes="http://agnes.sf.net/ns/agnes"
xsi:schemaLocation="http://agnes.sf.net/ns/agnes agnes.xsd"
agnes:id="AGID_1234567890abcdef">
<foo>
<bar/>
</foo>
</whatever>
------- whatever.xsd -----------------------------------------------

But XMLSpy outputs the following error:
'No Content Model available for validation (possibly empty DTD/Schema)'

=> So the question is: How can I declare an Attribute in it's own Schema so
that it can be used in different kinds of elements?
--
Bye, Thomas

'No Intensity, no Victory'
Any Given Sunday, 1999
Jul 20 '05 #1
1 2137
> I have the following problem: I want to have an XML-Schema that only
declares one Attribute, but does not specify in which specific Element it
has to be used. I've already tried the following:

------- agnes.xsd --------------------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schematargetNamespace="http://agnes.sf.net/ns/agnes"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified" xmlns="http://agnes.sf.net/ns/agnes">
<xsd:complexType name="agnesType">
<xsd:attribute name="id" type="idType"/>
</xsd:complexType>
<xsd:simpleType name="idType">
<xsd:restriction base="xsd:token">
<xsd:pattern value="AGID_[0-9a-zA-Z]{16}"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:schema>
------- agnes.xsd --------------------------------------------------
You do not need the complexType named "agnesType". Instead use a reference
to the attribute "id".

In the schema for your 'real' data import agnes.xsd:
<xsd:import schemaLocation="agnes.xsd"
namespace="http://agnes.sf.net/ns/agnes"/>

You can use a reference to an attribute from that schema, i.e.
<xsd:element name="whatever">
<xsd:complexType>
<xsd:sequence> ... </xsd:sequence>
<xsd:attribute ref="agnes:id"
xmlns:agnes="http://agnes.sf.net/ns/agnes"/>
</xsd:complexType
</xsd:element>
But XMLSpy outputs the following error:

I do not know if XMLSpy can understand the construction above since its
capabilities are quite limited when it comes to more complex schemas.

Jesper

--
Jesper Zedlitz eMail : je****@zedlitz.de
Homepage : http://www.zedlitz.de
ICQ# : 23890711
PGP-Key : http://zedlitz.de/pub_key.asc
Jul 20 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Robert J Egan | last post by:
Hi i'm trying to search a remote website page. The form returns xml information, though the page extension is missing. I retrieve the information and write it to the screen. So far so good -...
1
by: felipe_azv | last post by:
a got this code in asp to construct a xml , to export it to a url this is de asp code: <% SQL = "Select * from User where CodeUser in ("& request.form("C1" &")" set rs =...
2
by: Simon Strandgaard | last post by:
I am trying to understand how to create a 'catalog.xml' file for my docbook-xml documents. If I understand correct a local catalog.xml file can both avoid hardcoding in makefiles (portability),...
0
by: MarionEll | last post by:
Premier XML Industry Event Slated for Dec. 7-12 in Philadelphia; Presenters Include Adobe, BEA, Microsoft, IBM, Sun, Hewlett-Packard, Oracle Alexandria, Va. Sept. 30, 2003 - IDEAlliance, a...
0
by: MarionEll | last post by:
XML 2003 Exposition Draws Leading XML Vendors Trade Show, Presentations Allow Companies to Showcase Cutting-edge Solutions Alexandria, Va. - Dec. 1, 2003 - XML 2003, the world's largest XML...
3
by: David L | last post by:
Hi, I am wondering that whether the fact that as more tools/environments/products support XML, then the need for knowing XML itself gets less important. I am comparing xml to assembler. IT...
0
by: melledge | last post by:
The Reliable Source for Everything XML - XML 2005 Update XML 2005 - November 14-18 - Atlanta Hilton Hotel - Atlanta, GA www.xmlconference.org Register today and participate in IDEAlliance's...
5
by: laks | last post by:
Hi I have the following xsl stmt. <xsl:for-each select="JOB_POSTINGS/JOB_POSTING \"> <xsl:sort select="JOB_TITLE" order="ascending"/> This works fine when I use it. But when using multiple...
0
by: UncleRic | last post by:
Environment: Mac OS X (10.4.10) on MacBook Pro I'm a Perl Neophyte. I've downloaded the XML::Parser module and am attempting to install it in my working directory (referenced via PERL5LIB env): ...
9
by: Lie | last post by:
Why this generates AttributeError, then not? Python 2.5.2 (r252:60911, Apr 21 2008, 11:17:30) on linux2 Type "help", "copyright", "credits" or "license" for more information. Traceback (most...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.