Rectangle 27 3

XSD (XML schema definition) defines the element in an XML document. It can be used to verify if the elements in the xml document adheres to the description in which the content is to be placed. While wsdl is specific type of XML document which describes the web service. WSDL itself adheres to a XSD.

web services - what is the difference between XSD and WSDL - Stack Ove...

web-services wsdl xsd
Rectangle 27 1

This attribute has two values, separated by a space. The first value is the namespace to use. The second value is the location of the XML schema to use for that namespace. Which means the first part is not a real URI and can not be accessed, cause it's the namespace within the XSD and the second one is the XSD definition which can be used to check the xml file.

So this means in result there is no broken schema it is correct.

pom.xml - Maven: why does it contain a seemingly broken schemaLocation...

maven pom.xml
Rectangle 27 1

Here's how in XSD to declare that c has string content and an attribute named attr:

<xs:element name="c" minOccurs="0" maxOccurs="unbounded">
          <xs:complexType>
            <xs:simpleContent>
              <xs:extension base="xs:string">
                <xs:attribute name="attr" type="xs:string"/>
              </xs:extension>
            </xs:simpleContent>
          </xs:complexType>

Here's the entire DTD written as an XSD:

<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:element name="a">
    <xs:complexType>
      <xs:sequence>
        <xs:element name="b" minOccurs="0" type="xs:string"/>
        <xs:element name="c" minOccurs="0" maxOccurs="unbounded">
          <xs:complexType>
            <xs:simpleContent>
              <xs:extension base="xs:string">
                <xs:attribute name="attr" type="xs:string"/>
              </xs:extension>
            </xs:simpleContent>
          </xs:complexType>
        </xs:element>
        <xs:choice maxOccurs="unbounded">
          <xs:element name="d" type="xs:string"/>
          <xs:element name="e">
            <xs:complexType/>
          </xs:element>
        </xs:choice>        
      </xs:sequence>
    </xs:complexType>
  </xs:element>
</xs:schema>

usually I write <xsd:element name="test"> and not <xs:element name="test"> is it the same?

@ginogino yes, using xsd , xs, or any other prefix like p, xyz,y,etc. is the same thing, but the value of the prefix must be always (of course in this case) : http://www.w3.org/2001/XMLSchema.

From DTD to XSD (Document Type Definition to XML Schema) - Stack Overf...

xml xsd dtd
Rectangle 27 0

Unfortunately types as defined in an XML Schema (XSD) or Document Type Definition (DTD) are not directly tied to XML document they validate. The elements and attributes in an XML document do not inherently have a type they are just text. Think of an XSD as a script that validates an XML document rather than a set of type annotations for elements and attributes.

The XML specification does not define types as you are thinking of them here. Even Document Type Definitions (DTD) which can be embedded inside XML documents more about the structure of the document not the type of the data contained in elements and attributes.

The type system described in XML Schema is an optional layer of validation that can be applied to XML documents. Since this validation optional the standard XML APIs do not provide a way to bind the validation rules in an XSD to the actual attributes and elements.

I think it would be possible for an XML API to provide a mechanism to bind an XSD to a specific XML document, but I am not aware of an XML parser that does this. One reason why this is not so easy is that the type system that is defined in XML Schema is much richer than is supported in most mainstream programming languages. In your example you may only be interested in xs:integer, xs:string and the like but in XML Schema you can create types that specify ranges, patterns and other things that are just not possible with data types in most programming languages. To represent this complex type system in Java or any programming language would have to be done through a fairly complex API. The the question becomes it is really worth it? I would say probably not.

How can I get the xml Node type based on schema definition in Java? - ...

java xml schema
Rectangle 27 0

The answer to this one might be a bit subjective, but I'll share from my experience. Every browser I've ever used appropriately ignores any extra attributes that aren't part of an HTML spec - even very early versions of IE did this correctly. I've found it a handy technique for DOM manipulation, and recently as a helper for jQuery selectors. However, it's got some drawbacks and should be used sparingly. One of the drawbacks would be if you're using XHTML. In that case, you can't just make up your own stuff - you'd have to have a DTD or XSD that defines the attributes and then reference the schema definition as an XML namespace.

Just as an alternative suggestion... if it feels a little off to you to fake your own attributes, perhaps you might consider assigning a unique ID to your HTML elements using the ID attribute, which is valid on most if not every tag. Then, you can use a javascript dictionary to associate your element IDs with the variables you're trying to embed. The only reason you're using this is for javascript, right? I can't imagine any other reason this technique would be useful.

One more alternative would be to use a hidden tag as another poster suggested and then use jQuery's .next() selector http://api.jquery.com/next/.

dom - Question about HTML elements and custom attributes - Stack Overf...

html dom
Rectangle 27 0

You need to use simpleContent and extend it (defining the content as type string) like so to add the attribute:

<xs:element name="main">
    <xs:complexType>
      <xs:simpleContent>
        <xs:extension base="xs:string">
          <xs:attribute name="name" type="xs:string" use="required"/> 
        </xs:extension>
      </xs:simpleContent>
    </xs:complexType>
  </xs:element>

XSD definition for an XML tag with attribute and content - Stack Overf...

xml xsd
Rectangle 27 0

Difference is in formats of documents definitions. First is called DTD, second - XSD. Both are used to describe possible contents of xml document. DTD is older than XSD. XSD is more flexible and powerful than DTD. More differences you can see here.

Can you give me links of video tutorials can't find one that have good explanation and clear audio/english.

Sorry, I don't know such video tutorials. I can only recommend to read book: amazon.com/Pro-Spring-3-Clarence-Ho/dp/1430241071 It gives broad overview of spring features

Thanks a lot bro.

Difference between Spring DOCTYPE and tag - Stack Overflow

spring spring-mvc
Rectangle 27 0

In the XML schema definition, i.e. XSD file, attributes are optional by default. To make an attribute required, you have to define:

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

You will find a very good introduction on XML and XML Schema Definitions, i.e. XSD, on W3 Schools.

In Java the equivalent of defining a XML schema is using JAXB, i.e. Java API for XML Binding that is included into Java SE. There you would define, e.g.

@XmlRootElement
public class Person { public @XmlAttribute(required=true) String surname; }

I know how to define required attributes in XSD, but this is not my task. I just want to insert all required atributes in XML

Once you have JAXB classes, representing your XML entities, you can use Reflection to query annotations for required attributes.

java - How to detect required XML attributes? - Stack Overflow

java xml xsd xml-parsing
Rectangle 27 0

XSD (XML schema definition) defines the element in an XML document. It can be used to verify if the elements in the xml document adheres to the description in which the content is to be placed. While wsdl is specific type of XML document which describes the web service. WSDL itself adheres to a XSD.

web services - what is the difference between XSD and WSDL - Stack Ove...

web-services wsdl xsd
Rectangle 27 0

You're looking for a xsd definition to make <AccountNo> or <MSNumber> or both but not any valid. The usual way to do so is combining <xs:choice>, <xs:sequence>and minOccurs attribute. Please note that in your xsd your element name is MSISDN and in your XML is MSNumber, I use MSNumber as in your XML, here is my solution:

<schema xmlns="http://www.w3.org/2001/XMLSchema">
...
<element name="AccountNo" type="string"/>
<element name="MSNumber">
    <simpleType>
        <restriction base="string">
            <pattern value="\d{10,18}|"></pattern>
        </restriction>
    </simpleType>
</element>
<element name="LineService" maxOccurs="unbounded" minOccurs="1">
    <complexType>
        <sequence>
            <element type="string" name="LineSrId" maxOccurs="1" minOccurs="0" nillable="true"/>
            <xs:choice>
                <xs:sequence>
                    <xs:element ref="MSNumber"/>
                    <xs:element ref="AccountNo" minOccurs="0"/>
                </xs:sequence>
                <xs:element ref="AccountNo"/>
            </xs:choice>            
        </sequence>
    </complexType>
</element>
...
</schema>

xml - xsd validation for tag value not null - Stack Overflow

xml tags xsd xsd-validation
Rectangle 27 0

An element with a simple type can't have attributes. You need a "complex type with simple content", which is defined using an xs:complexType element with an xs:simpleContent child.

xsd - XML Schema validator error on attribute definition - Stack Overf...

xml xsd xsd-validation
Rectangle 27 0

Your first question is "When adding restrictions to complexTypes in XML Schemas, is it necessary to rewrite all the elements used in the definition of the complexType?" No, only the ones you want to be part of the definition of the restricted type. But yes, all of the ones that should be part of the restriction. The content model in the restriction must stand on its own as a complete definition of the content model of the type. (It does not, on the other hand, have to specify all the attributes; they are inherited without change unless otherwise specified.)

Your second question is "Why can't it just reuse the existing element definitions and overwrite the new restricted ones?" It's a reasonable question. The answer is slightly tricky: Consider two arbitrary content models E and F. Now, we want to interpret F as a restriction of E that mentions only the elements and model groups in E that we want to change, and omits any mention of the elements and model groups we want alone. Is this a soluble problem, in the general case? Is it guaranteed to have a unique solution? It may seem obvious to you that the answer is yes in both cases, but it did not seem obvious to the designers of XSD at the time, and it does not seem obvious to me today.

(a+, b+, c*){2}, (a+, b*, c+){3}

and let F be

a{3,4}

If we assume that everything in F is a restriction of something in E and everything else in E should be left alone, does F mean we want to restrict E to

(a{3,4}, b+, c*){2}, (a+, b*, c+)
(a+, b+, c*){2}, (a{3,4}, b*, c+)

@nikel asks for an XSD example. The example above is already an XSD example, though, so I suppose "an example in XSD syntax" is meant. I take the proposal to be that syntax like the following should work. First we have the base type, E:

<xs:complexType name="E">
  <xs:sequence>
    <xs:sequence minOccurs="2" maxOccurs="2">
      <xs:element ref="a" maxOccurs="unbounded"/>
      <xs:element ref="b" maxOccurs="unbounded"/>
      <xs:element ref="c" minOccurs="0" 
                          maxOccurs="unbounded"/>
    </xs:sequence>
    <xs:sequence minOccurs="3" maxOccurs="3">
      <xs:element ref="a" maxOccurs="unbounded"/>
      <xs:element ref="b" minOccurs="0" 
                          maxOccurs="unbounded"/>
      <xs:element ref="c" maxOccurs="unbounded"/>
    </xs:sequence>
  </xs:sequence>
</xs:complexType>

Now let us imagine that we want type F to be able to restrict E without specifying a full content model. So we write

<xs:complexType name="F">
  <xs:complexContent>
    <xs:restriction base="tns:E">
      <xs:sequence>
        <xs:element ref="a" minOccurs="3" maxOccurs="4"/>          
      </xs:sequence>        
    </xs:restriction>
  </xs:complexContent>
</xs:complexType>

What should the effective content model of F be here?

You ask, essentially, "in that case, what's the use of restriction?"

Reasonable question. The answer you suggest is a good one. More generally, sometimes we find it useful to know that every instance of type B* will be an instance of type B; derivation by restriction in XSD is intended to guarantee that invariant. Sometimes it seems helpful to define an abstract type with two or more concrete restrictions; that helps ensure that the various concrete realizations of the abstract base type are nicely related to each other, even if none is a subset or superset of any other.

There could be (no: there are plenty of) ways that derivation by restriction could be made clearer, simpler, and more convenient in XSD; not having to repeat the entire content model would be one of them. But then, that's true for pretty much everything in XSD. Its only real virtue is that it is supported by a lot of tools a lot of people seem to want to use.

Looks sensible for DTD's. Could you give a similar example for XSD's where this problem does not have a guranteed solution?

I'm afraid I don't understand the question. Do you mean you would like to see this example in XSD syntax? Nothing in the example depends on the particular syntax used (nor is the syntax used the syntax of DTDs).

Yeah , I meant it in the XSD Syntax as you put it up.Sorry for my lack of knowledge of DTD , I thought it was in DTD.

Got the reason now. Thanks for rephrasing your Excellent answer!. I added a follow up Question , Can you check that?

Love the Way You answer! :)

xsd - XML Schema Restriction for Complex types : Complete Redefinition...

xml xsd
Rectangle 27 0

The answer to this one might be a bit subjective, but I'll share from my experience. Every browser I've ever used appropriately ignores any extra attributes that aren't part of an HTML spec - even very early versions of IE did this correctly. I've found it a handy technique for DOM manipulation, and recently as a helper for jQuery selectors. However, it's got some drawbacks and should be used sparingly. One of the drawbacks would be if you're using XHTML. In that case, you can't just make up your own stuff - you'd have to have a DTD or XSD that defines the attributes and then reference the schema definition as an XML namespace.

Just as an alternative suggestion... if it feels a little off to you to fake your own attributes, perhaps you might consider assigning a unique ID to your HTML elements using the ID attribute, which is valid on most if not every tag. Then, you can use a javascript dictionary to associate your element IDs with the variables you're trying to embed. The only reason you're using this is for javascript, right? I can't imagine any other reason this technique would be useful.

One more alternative would be to use a hidden tag as another poster suggested and then use jQuery's .next() selector http://api.jquery.com/next/.

dom - Question about HTML elements and custom attributes - Stack Overf...

html dom
Rectangle 27 0

I wasn't clear enough in my question originally, so I'll clarify and answer it myself. I was originally outputting a hardcoded string in PHP to use as an xml .xsd schema, which dosn't allow for dynmaically changing the definition to add new elements or attributes. I ended up using SimpleXML to create my .xsd string (which can also be saved as a file).

$xmlSchema = new SimpleXMLElement('<xmlns:xsd:schema></xmlns:xsd:schema>', LIBXML_NOERROR, false, 'xsd', true);
$xmlSchema->addAttribute('xmlns:xmlns:xsd', 'http://www.w3.org/2001/XMLSchema');
$newelement = $xmlSchema->addChild('xsd:xsd:element');
$newelement->addAttribute('name', 'metadata');
$newelement = $metaelement->addChild($elmprefix.'complexType');
$sequence = $newelement->addChild($elmprefix.'sequence');

xml - Dynamically create and update an .xsd schema in PHP? - Stack Ove...

php xml xsd simplexml xml-namespaces
Rectangle 27 0

<xs:choice> selects one among many. You have nested choices. The parser complains that there is ambiguity because you have repeating elements declared in the neste choices, violating the Unique Particle Attribution constraint.

Example: If the first nested choice chooses A, and the second one also chooses A, you will have this illegal situation in your outer choice:

<xs:choice>
    <xs:element name="A"/>
    <xs:element name="A"/>
</xs:choice>

You can have one nested choice and accept multiple A elements, but not two identical element declarations.

Your code will work if you replace the outer choice for a sequence.

can you please review this question stackoverflow.com/questions/23149300/ i want to solution of this question please help me.

See the explanation in that page you referred above in the answer by @C-M-Sperberg-McQueen.

xml - XSD Schema Error : the content model of complex type definition ...

xml xsd xsd-validation
Rectangle 27 0

Such a model would violate the constraint "Element Declarations Consistent", which requires that if two element particles in a content model have the same name then they must have the same type.

You can do it in XSD 1.1, of course, using assertions.

xml - XSD: define 2 elements with the same name but exact definition o...

xml xsd