Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Self-closing tag is a non-text node whereas empty tag is a text node #18

Closed
gxa opened this issue Jul 19, 2017 · 3 comments
Closed

Self-closing tag is a non-text node whereas empty tag is a text node #18

gxa opened this issue Jul 19, 2017 · 3 comments
Labels

Comments

@gxa
Copy link

gxa commented Jul 19, 2017

<tag id="foo"/> and <tag id="foo"></tag> are treated differently. To parse the attributes in the first case you need to specify ignoreNonTextAttr: false and for the second case ignoreTextAttr:false. Also, the second tag will have a #text field and the first one won’t. I think this behaviour doesn’t match the XML spec, as the two should be equivalent:

Empty-element tags may be used for any element which has no content, whether or not it is declared using the keyword EMPTY. For interoperability, the empty-element tag SHOULD be used, and SHOULD only be used, for elements which are declared EMPTY.

Examples of empty elements:

<IMG align="left"
src="http://www.w3.org/Icons/WWW/w3c_home" />
<br></br>
<br/>

@amitguptagwl
Copy link
Member

amitguptagwl commented Jul 19, 2017 via email

@amitguptagwl
Copy link
Member

@gxa Though the both tags should be treated equally, in the parser user can decide weather he wants to ignore attributes of one type or of both type. So if many users of parser library feel that I should make it one, I'll do that.

#text is the field when you don't ignore attributes and want to parse the tag with attribute as well as tag value. Eg <tag attr="val">textval</tag>.

Let me know if you have any other doubt.

@amitguptagwl
Copy link
Member

Please raise the other issue if you still have any doubt.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants