473,385 Members | 1,402 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: 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
6 1923
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Zombie | last post by:
Hi all, I wish to create a namespace other than the default one. Let's say, the Schema looks like: ----------------------------------------------------------------------- <?xml version="1.0"...
1
by: Lee Chapman | last post by:
Has anyone successfully been able to use an XmlValidatingReader (Framework 1.1) to validate documents against XML Schemas that haven't been added to the XmlValidatingReader.Schemas collection...
6
by: Martin | last post by:
Hi, I have a xml file like the one below <?xml version="1.0" encoding="utf-8"?><e1 xmlns:e1="http://tempuri.org/Source1.xsd" e1:att1="1" e1:att2="2" e1:rest="345"/> If I try to create a...
2
by: Chuck Bowling | last post by:
AIML Schema: http://209.168.21.76/CommunityStarterKit/Downloads/258.aspx I have a Schema (in the link above) that I've been trying to make work in VS2003 for a while now and just can't seem to...
3
by: Kiran | last post by:
Hi, I want to back up my data in some table in SQL server and import it back using Bulk Load of SQL server 2K. I can use the following code to backup the data in XML ...
0
by: WideBoy | last post by:
Dear Group, I have recently started working with a large XML schema built to expose a domain specific data model in XML. I was wondering if any one has any ideas on how best to develop an XML...
9
by: mstilli | last post by:
Hi, I am trying to use schema for server side validation using xerces to catch the validation errors. validating this XML: <Content4> <textarea13></textarea13>...
5
by: orabalu | last post by:
Hi Guys, Can you give me some examples for Incremental load in PL/SQL for Datawarehouse projects. Regards, Balu
3
by: Kai Schlamp | last post by:
Hello! In my schema I have the following: <xs:complexType name="textareaType"> <xs:simpleContent> <xs:restriction base="xs:string"> <xs:attribute ref="label" use="required" />...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.