<?xml version="1.0"?>
<syntax name="language-root.xml">
	<zones>
		<zone name="comment.block.xml">
			<starts-with>
				<expression>&lt;!--</expression>
				<capture number="0" name="punctuation.definition.begin"/>
			</starts-with>
			<ends-with>
				<expression>--></expression>
				<capture number="0" name="punctuation.definition.end"/>
			</ends-with>
		</zone>
		<zone name="comment.cdata.xml">
			<starts-with>
				<expression>&lt;!\[CDATA\[</expression>
				<capture number="0" name="punctuation.definition.begin"/>
			</starts-with>
			<ends-with>
				<expression>\]\]></expression>
				<capture number="0" name="punctuation.definition.end"/>
			</ends-with>
		</zone>
		<zone name="tag.self-closing.processing-instruction.xml">
			<starts-with>
				<expression>(&lt;\?)([a-zA-Z0-9_-]+)</expression>
				<capture number="1" name="punctuation.definition.begin"/>
				<capture number="2" name="name"/>
			</starts-with>
			<ends-with>
				<expression>\?></expression>
				<capture number="0" name="punctuation.definition.end"/>
			</ends-with>
			<subzones>
				<include collection="tag-attributes"/>
			</subzones>
		</zone>
		
		<include collection="tags" />
	
	</zones>
	
	<library>
		
		<collection name="tags">
			<zone name="tag.open.xml">
				<starts-with>
					<expression>(&lt;)([a-zA-Z0-9:_-]+)</expression>
					<capture number="1" name="punctuation.definition.begin"/>
					<capture number="2" name="name">
						<subzones>
							<zone>
								<expression>([^:]+)(:)(.*)</expression>
								<capture number="1" name="namespace"/>
								<capture number="2" name="punctuation.separator"/>
								<capture number="3" name="localname"/>
							</zone>
						</subzones>
					</capture>
				</starts-with>
				<ends-with>
					<expression>(/?)(>)</expression>
					<capture number="1" name="punctuation.definition.self-closing"/>
					<capture number="2" name="punctuation.definition.end"/>
				</ends-with>
				<subzones>
					<include collection="tag-attributes"/>
				</subzones>
			</zone>
			<zone name="tag.close.xml">
				<starts-with>
					<expression>(&lt;/)([a-zA-Z0-9:_-]+)</expression>
					<capture number="1" name="punctuation.definition.begin"/>
					<capture number="2" name="name">
						<subzones>
							<zone>
								<expression>([^:]+)(:)(.*)</expression>
								<capture number="1" name="namespace"/>
								<capture number="2" name="punctuation.separator"/>
								<capture number="3" name="localname"/>
							</zone>
						</subzones>
					</capture>
				</starts-with>
				<ends-with>
					<expression>></expression>
					<capture number="0" name="punctuation.definition.end"/>
				</ends-with>
				<subzones>
					<zone name="invalid">
						<expression>[^\s>]+</expression>
					</zone>
				</subzones>
			</zone>
		</collection>
	
		<collection name="tag-attributes">
			<zone>
				<expression>\s+([a-zA-Z0-9:_-]+)(=)</expression>
				<capture number="1" name="attribute-name">
					<subzones>
						<zone>
							<expression>([^:]+)(:)(.*)</expression>
							<capture number="1" name="namespace"/>
							<capture number="2" name="punctuation.separator"/>
							<capture number="3" name="localname"/>
						</zone>
					</subzones>
				</capture>
				<capture number="2" name="punctuation.separator.attribute"/>
				<capture number="3" name="punctuation.separator.namespace"/>
			</zone>
			<include collection="strings"/>
		</collection>
		
		<collection name="strings">
			<zone name="attribute-value.string.quoted">
				<starts-with>
					<expression>("|')</expression>
					<capture number="0" name="punctuation.definition.begin"/>
				</starts-with>
				<ends-with>
					<expression>\1</expression>
					<capture number="0" name="punctuation.definition.end"/>
				</ends-with>
				<subzones name="attribute-value.value" />
			</zone>
		</collection>
		
	</library>
</syntax>
