XML, XPath, and XSLT technology quiz/Questions

Here are some ideas for technical interview questions for XML/XSLT consultants:

Programming

 * 1) What's the difference between a statement and an expression?
 * 2) What's the difference between procedural (or imperative) programming and declarative programming?
 * 3) * Which of these would XSLT be?
 * 4) What is functional programming?
 * 5) If a function is said to have "side effects", what does that mean?
 * 6) What is memoization?
 * 7) * How might memoization apply to XPath or XSLT?
 * 8) What different things might an " " mean in something like " "?
 * 9) * Is this the same as it means in mathematics?
 * 10) * Which definition is closer to the concept of the evaluation of expressions?
 * 11) * Alternatively, what's the difference between " " as used in assignment and comparison?
 * 12) * What's the difference between identity, equality, and equivalence?

General document processing

 * 1) What is a URI? What's the difference between a URL and a URI?
 * 2) What is a "base URI"?

Character codes

 * 1) In XML and HTML, what does the number in a numeric character reference like " " refer to?
 * 2) In XML and HTML, what does the " " in the entity reference " " mean?
 * 3) In XML, what are the built-in entities?
 * 4) * Which one is not also in HTML?
 * 5) In XML, when would you use the " " or " " entities?

Structure

 * 1) In XML, what's the difference between well-formed and valid?
 * 2) In XML, what is a   tag?
 * 3) In XML, what information is in a DTD?
 * 4) In XML, what's the thing at the top of most XML documents that starts with " "?
 * 5) * What's the difference between a processing instruction and an XML declaration?
 * 6) * Bonus question: what's a text declaration?
 * 7) In XML, what does the encoding declaration indicate?
 * 8) * How is it used?
 * 9) * What is the equivalent in HTML?

Namespaces

 * 1) What's a namespace?
 * 2) What's a namespace declaration, and is it considered an attribute?
 * 3) What does the URI in a namespace declaration denote?
 * 4) What's the scope of a namespace declaration?
 * 5) * If a namespace declaration is on an element, does it apply to the attributes as well?
 * 6) If an XML document has no namespaces, what does it mean if you add   to the top?
 * 7) What happens if element names have prefixes that aren't in scope? Are they in no namespace?
 * 8) What namespace bindings are in effect by default?
 * 9) What's the relationship between a QName and an expanded name?
 * 10) * Alternatively, what's the difference between an element or attribute's name, its local name, its prefix, and its namespace?
 * 11) Can you rebind a prefix that is already in scope?
 * 12) Can you rebind a prefix to the null namespace?
 * 13) Can you "undeclare" namespaces (make a prefix no longer be bound at all)?

Processing

 * 1) What does an XML parser do?
 * 2) * Where does it sit in an XML document processing workflow?
 * 3) * What about in the XSLT processing workflow?
 * 4) In XML, what kind of information does the parser read, and what does it report?
 * 5) * Alternatively (giving away the answer), what's the difference between the raw content of an XML document, and the logical information that's guaranteed to be exposed to the application?
 * 6) * Will any of the lexical information be exposed to the application?

Data model

 * 1) What is an Infoset?
 * 2) What are some differences between the W3C DOM and XPath tree models?
 * 3) What information does a schema provide?
 * 4) * What are the dominant schema languages? Compare and contrast.

Miscellaneous

 * 1) What are some of the major differences between XML 1.0 and XML 1.1?
 * 2) * Which should you use?

XPath

 * 1) In XPath (not XSLT), how do you set a variable?
 * 2) In XPath (not XSLT), how do you bind a namespace prefix?
 * 3) In XPath, what are the fundamental object types?
 * 4) * Is it possible to have any others?
 * 5) * What is an example of how you would identify or create an object of each of those types in an XPath expression?
 * 6) How would you refer to an empty node-set?
 * 7) Is an empty node-set true or false?
 * 8) * What about an XSLT 1.0 result tree fragment?
 * 9) What is an axis?
 * 10) * Name and describe some of them.
 * 11) What is a node-set? What order are the nodes in?
 * 12) What is document order?
 * 13) What is a predicate and what is it for?
 * 14) What does a predicate that is just a digit (like "[1]") mean?
 * 15) In XPath 1.0, what does "*" mean? What does it imply about namespaces?
 * 16) In XPath 1.0, how would you select elements in a non-null namespace?
 * 17) In XPath 1.0, what does an equality comparison of two node-sets evaluate to?
 * 18) * That is, what would " " (without the quotes) mean? What about " "?
 * 19) In XPath 1.0, what is the difference between " " and " "?
 * 20) In XPath, how can you determine that node "x" is a member of a node-set "y"?
 * 21) * Similarly, how can you determine that two expressions identify the same node?
 * 22) In XPath, what's the "context"?
 * 23) What are some of the major differences between XPath 1.0 and 2.0?
 * 24) * Which should you use?

XSLT

 * 1) In XSLT, what's the "context"?
 * 2) * How is it different from the XPath context?
 * 3) In XSLT 1.0, how would you produce XHTML output?
 * 4) If producing output for modern web browsers, would you opt to produce XHTML 1.0, HTML 4, or HTML5, and why? Which is better?
 * 5) What's the difference between   and  ?
 * 6) What does   do?
 * 7) What's the difference between   and  ?
 * 8) What are template priorities, and when would you override them?
 * 9) What's the difference between   and  ?
 * 10) What's the usefulness of imports?
 * 11) What happens if two templates match the same node at the same priority and import precedence?
 * 12) In XSLT, how do you read from different source documents?
 * 13) * Can those documents be in any format?
 * 14) In XSLT, when iterating over nodes, how would you ensure that a separator appears in between the output you generate for each node?
 * 15) * How would you go about producing different output for every other node (e.g., alternating table row background colors)?
 * 16) What methods can you use for grouping?
 * 17) * For example, given a set of 10 sibling elements, how would you produce output saying that 4 of them had one string-value, and 6 of them had another, without knowing the string-values in advance?
 * 18) * Phrased another way (and giving away part of the answer), how would you select just the nodes that are the first (or last) with their string-value?
 * 19) * Is there another method you know about? Why would you use one method or the other?
 * 20) * What would you do if the nodes were not immediate siblings?
 * 21) When would you want to use template modes?
 * 22) In XSLT, what are the "push" and "pull" approaches to processing, and when would you prefer one over the other?
 * 23) How would you generate a table of contents?
 * 24) What's the difference between the current node and the context node?
 * 25) * When do you use the  function?
 * 26) In XSLT, what does   do, and what would be an example of its use?
 * 27) * What does the  function return?
 * 28) * How do you control what documents the  function looks in?
 * 29) * Technical writing bonus: What's wrong with writing " function"?
 * 30) In XSLT, how would you create a variable that is just a string?
 * 31) * What if the string needed to contain quotation marks or apostrophes?
 * 32) In XSLT 1.0, what is a result tree fragment?
 * 33) In XSLT 1.0, how would you make a variable's value be conditional? What if the variable needed to be a node-set?
 * 34) In XSLT, what is the " " or " " extension function?
 * 35) What is EXSLT?
 * 36) In XSLT, what is disable-output-escaping?
 * 37) * When would you use it?
 * 38) * What are its risks?
 * 39) In XSLT, if your stylesheet contains literal result elements without namespace declarations, but they are output with unwanted declarations that appear to have been copied from the top level of the stylesheet, what would you do?
 * 40) What's the difference between an XPath expression and an XSLT pattern?
 * 41) In XSLT, how would you create output that is identical to the input?
 * 42) * Would the output XML really be 100% identical to the input?
 * 43) * How would you create output that is identical to the input except for changing all elements named "x" to be named "y"?
 * 44) In HTML, you can use " " to represent a no-break space. Can you do this in XML too? How?
 * 45) * What other representations of no-break space are available, and how are they different from each other?
 * 46) * In XSLT, how would you create a no-break space in HTML output?
 * 47) * Is it necessary to produce " "?
 * 48) * How can you encourage the XSLT processor to emit " ", and can this be forced?
 * 49) In XSLT, how do you embed data in the stylesheet?
 * 50) In XSLT 1.0, how can you output the current date and time?
 * 51) In XSLT 1.0, how would you process nodes in sorted order (say, alphanumerically by their string-value)?
 * 52) * What if the sort needed to be case-insensitive?
 * 53) What are some of the major differences between XSLT 1.0 and 2.0?
 * 54) * Which should you use?