====== XML / XSL notes ====== * [[http://www.kohsuke.org/xmlschema/XMLSchemaDOsAndDONTs.html|W3C XML Schema: DOs and DON'Ts]] after Kohsuke Kawaguchi. * [[http://xpath.me/|Nice service]] to show visually matched XML nodes. * [[http://www.xmlplease.com/whitespace|Tricky whitespace handling in XSLT]] shows how to deal with space characters, carriage returns, line feeds or tabs. === [[stackoverflowa>2155970/267197|How to exclude given node from output XML tree?]] === Suppose we have an XML tree from which we need to exclude the node ''''. That means the resulting tree should have all siblings and children of this node, but not the node itself. === Why XML attributes declared as separate '''' entry should be used with explicit namespace prefix in XML? === This XML does not validate: Following XML samples validate fine: [[stackoverflowa>27644400/267197|Because such XML attributes form separate (independent) namespace group "Global Attribute Partition"]], thus they don't match element namespace even if they are literally the same. Solution: either copy attribute declaration to each reference or use '''': === How to implement stylesheet that will generate another stylesheet? === The given XSL will generate another XSL as output. All output XML elements need to be generated using '''' otherwise they cannot be separated from instructions of current XSL. In order to generate extra namespaces, which are not explicitly used in resulting XML, we need to use a workaround described in [[stackoverflowa>12182435/267197|Create xmlns attribute in the XML using XSLT Transformation]], namely create a dummy node set and use extension to copy it's namespaces to current node. It's handy to extra common logic into separate XSL and import it. 1.0 common.xsl //extra:document[]/extra:number[text()=''] text()