467,927 Members | 1,868 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 467,927 developers. It's quick & easy.

Xml schema: how to achieve <!ENTITY x "y">

I have an XML Schema with regular expressions.

e.g. <xsd:pattern value="[a-zA-Z]{1}[a-zA-Z0-9._=+-]*"/>

I have other patterns in the same schema document which share regular
expression substructure, like the string "[a-zA-Z0-9._=+-]"

I'd like to do something like:

<!ENTITY substring_pattern "[a-zA-Z0-9._=+-]">

And revise my xml schema to look like:

<xsd:pattern value="[a-zA-Z]{1}&substring_pattern;*"/>
I can't figure out how to generate a reusable literal that can be
embedded in attribute values within an XML schema document.

<!ENTITY> isn't valid xml in an XML schema, at least not as far as my
tests have shown in attempting to validate with a schema using such
declarations.
HELP!
Signed,
cut-and-pasting-for-now-but-tired-of-it
--
----------

Email from unknown persons will be blocked by spam filters.
Please post replies to the news conference. Thank you.

Jul 20 '05 #1
  • viewed: 1745
Share:
6 Replies
In article <pjlbc.163534$Cb.1653348@attbi_s51>,
Phil Jarvis <ph************@sybase.com> wrote:
I can't figure out how to generate a reusable literal that can be
embedded in attribute values within an XML schema document.


Schemas don't provide an entity-like mechanism: they just do the
validation bit of DTDs. if you want an entity, put a DTD on your
schema and define one in the usual way.

-- Richard
Jul 20 '05 #2
I suspect that if I do what you suggest, presumably something like

<!DOCTYPE MySchema SYSTEM "MySchema.dtd">

for an XML schema document which otherwise looks like this:

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

That both attempts to
(a) run it as input for schema validated xml content or
(b) run it as input for xml validation against the dted

would be a disaster. (I'd have to define the whole
XML Schema in the dtd, for starters, and XML Schema validators would
probably STILL choke on the <!DOCTYPE > statement).

DTD's and XML schema don't mix, I suspect, with the schema validation
tools I use. So I must be missing what you had in mind. Could you give
me an example?

(FYI: I'm just using Sun J2SE 1.4.2 tools)

Richard Tobin wrote:
In article <pjlbc.163534$Cb.1653348@attbi_s51>,
Phil Jarvis <ph************@sybase.com> wrote:

I can't figure out how to generate a reusable literal that can be
embedded in attribute values within an XML schema document.

Schemas don't provide an entity-like mechanism: they just do the
validation bit of DTDs. if you want an entity, put a DTD on your
schema and define one in the usual way.

-- Richard


--
----------

Email from unknown persons will be blocked by spam filters.
Please post replies to the new conference. Thank you.

Jul 20 '05 #3
see for example http://java.sun.com/dtd/jspxml.xsd
"View source" if you don't see the DOCTYPE etc.

with respect,
Toni Uusitalo
Jul 20 '05 #4
In article <teFbc.67340$JO3.39105@attbi_s04>,
Phil Jarvis <ph************@sybase.com> wrote:
I suspect that if I do what you suggest, presumably something like

<!DOCTYPE MySchema SYSTEM "MySchema.dtd">

for an XML schema document which otherwise looks like this:

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

That both attempts to
(a) run it as input for schema validated xml content or
(b) run it as input for xml validation against the dted

would be a disaster. (I'd have to define the whole
XML Schema in the dtd, for starters, and XML Schema validators would
probably STILL choke on the <!DOCTYPE > statement).


There's a DTD for schemas at http://www.w3.org/2001/XMLSchema.dtd, but
you don't need to use a complete DTD, just an internal subset with the
entity you want. Of course if you validate it against an incomplete
DTD it will be invalid, but you don't have to DTD-validate just to use
an entity declaration.

XML Schemas are XML documents, so no Schema validator should "choke"
on a DOCTYPE statement. All XML processors are required to process
the internal subset, so if you put your entity declaration there it
should work.

-- Richard
Jul 20 '05 #5
Lots of good advice in these replies. I'll try it out.

Thanks!

Richard Tobin wrote:
In article <teFbc.67340$JO3.39105@attbi_s04>,
Phil Jarvis <ph************@sybase.com> wrote:
I suspect that if I do what you suggest, presumably something like

<!DOCTYPE MySchema SYSTEM "MySchema.dtd">

for an XML schema document which otherwise looks like this:

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

That both attempts to
(a) run it as input for schema validated xml content or
(b) run it as input for xml validation against the dted

would be a disaster. (I'd have to define the whole
XML Schema in the dtd, for starters, and XML Schema validators would
probably STILL choke on the <!DOCTYPE > statement).

There's a DTD for schemas at http://www.w3.org/2001/XMLSchema.dtd, but
you don't need to use a complete DTD, just an internal subset with the
entity you want. Of course if you validate it against an incomplete
DTD it will be invalid, but you don't have to DTD-validate just to use
an entity declaration.

XML Schemas are XML documents, so no Schema validator should "choke"
on a DOCTYPE statement. All XML processors are required to process
the internal subset, so if you put your entity declaration there it
should work.

-- Richard


--
----------

Email from unknown persons will be blocked by spam filters.
Please post replies to the new conference. Thank you.

Jul 20 '05 #6
Just a followup, the answers (provided in replies) to my questions
worked just fine against schema validation tools and such when I tried them.

Thanks for your help.

--
----------

Email from unknown persons will be blocked by spam filters.
Please post replies to the new conference. Thank you.

Jul 20 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Zombie | last post: by
1 post views Thread by Lee Chapman | last post: by
2 posts views Thread by Chuck Bowling | last post: by
3 posts views Thread by Kiran | last post: by
reply views Thread by WideBoy | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.