validation

elem = document.createElement(tagName);

I am not appending this 'elem' in markup document

1) The above document is a markup document. So, is it necessary to create an element with tagName(like div, p, timing....) mentioned in schema or can we use any user tagName

2) Will there be validation with schema for those elements and attributes created(not appended) at run time

3) If i append any element(that is not mentioned in schema) at run time, what will happen

Thanks in advance



Answer this question

validation

  • Peteraap

    Thanks peter. I want to test working behaviour of createElement() API in document. So, I had a doubt that using any tagName other than in schema will cause some problem.
  • Toni Greco

    Thanks peter. My doubt is whether we can create a element with any tagName (elem=document.createElement("yyy")). I am not appending this element(elem) anywhere in document. Is this also a invalid one
  • my name is not earl

    Creating an element without inserting it into the document shouldn't make the document invalid. Nevertheless, with something like this that will be running on lots of different CE devices and software players, I would personally shy away from anything too weird "just in case."

    Is there a particular reason why you want to do this There may be a better way to achieve the same result.



  • Rossman1012

    The spec says that documents SHOULD be valid per their schemas, but that players MUST NOT try to validate against external schemas (see 6.2.1 in the spec). Players also aren't required to do any validation, but if the document is invalid then the behaviour is undefined.

    What this basically means is that if you want to add random tags to a markup document, you should add them in your own custom namespace to guarantee that it won't be considered invalid.



  • validation