[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

Re: [xsl] Help please: question on xml's schema and xslt

Subject: Re: [xsl] Help please: question on xml's schema and xslt
From: "Wolfgang Laun wolfgang.laun@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Fri, 1 Aug 2014 13:12:49 -0000

On 01/08/2014, L2L 2L emanuelallen@xxxxxxxxxxx
<xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote:
> I have ask on many different forums; visionzone, sitepoint, oreilly, even
> ask an author of a book, but receive no reply. I have even try
> stackexchange. This doesn't make sense....

> ----question 2-------
> Is this legal:
> <?xml version="1.0" encoding="UTF-8"?> <xs:schema
> xmlnss="http://www.w3.org/2001/XMLSchema"> <xs:annotation>
> <xs:documentation> I'm warping a name simpleType name nameType in an
> that have the attribute type with the value of nameType. Is this legal; to
> warp a name type as so: </xs:documentation> </xs:annotation> <xs:element
> name="name" type="nameType"> <xs:simpleType name="nameType">
> base="xs:string"> <xs:length value="25"/> </xs:restriction>
> </xs:element> </xs:schema>

(Indendation is the politeness of list users.)

No it is NOT - Element 'name' has both a 'type' attribute and a
'anonymous type' child. Only one of these is allowed for an element.

Use this;

    <xs:element name="name" type="nameType"/>
    <xs:simpleType name="nameType">
      <xs:restriction base="xs:string">
        <xs:length value="25"/>

> -----question 3--------
> What are extension and restriction type?

Perhaps risk a short look on the XML Schema spec:

[Definition:]  A complex type definition which allows element or
attribute content in addition to that allowed by another specified
type definition is said to be an extension.

[Definition:]  A type defined with the same constraints as its 7base
type definition7, or with more, is said to be a restriction.  The
added constraints might include narrowed ranges or reduced
alternatives. Given two types A and B, if the definition of A is a
7restriction7 of the definition of B, then members of type A are
always locally valid against type B as well.

> ----question 4---------
> First question:

(Actually the 4th.)

> Can I place an extension on a restriction type?
> And if so, how? Via what method? Directly? Via reference? Both?
> And if so for both, what other ways?

The excellent Primer on XML Schema http://www.w3.org/TR/xmlschema-0/
contains numerous examples for both.

> Second question:

(Actually it's the 5th.)

> targetNameSpace is to set a name space for the xml element in my schema?
> or no then an explanation comment please.

This isn't well formulated. If you mean "for the XML elements defined
by <xs:element>" then the answer is: "yes, but not only for these,
also for <xs:complextType>, <xs:simpleType> and other Schema
components defined and named (!) in that XML schema.

> a xmlnssi="uri" is to set the prefix for the xsi namespace and a
> xsi:noNamespaceSchemaLocation="uri" is to set the location of my schema?
> or no, then a feedback comment please.

You mean "xmlns:xsi=...".

a) No, it defines the prefix "xsi" for the namespace uniquely
identified by "uri".

b) Yes, but only if you associate the prefix xsi to this URI:

> is the targetNameSapce needed... I find it non-necessary to do when it
> can(by what I'm reading) define top level element and complex type(another
> question is that by definning type level complex type, do that also mean
> that type level complex when use in a element that is nested in another
> element gain the namespace too?). I find it unnecessary to use
> targetNameSapce when it doesn't cover all element being defined in the
> schema.

No, you need not use targetNameSpace. You may run into difficulties if
you try use different XML schema definitions without target namespaces
but with conflicting definitions.


> informational feedback please anyone!
> E-S4L

Current Thread