XML, XPath, and XSLT technology quiz/Questions

From Offset
Jump to navigationJump to search

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?
    • Which of these would XSLT be?
  3. What is functional programming?
  4. If a function is said to have "side effects", what does that mean?
  5. What is memoization?
    • How might memoization apply to XPath or XSLT?
  6. What different things might an "=" mean in something like "x=1"?
    • Is this the same as it means in mathematics?
    • Which definition is closer to the concept of the evaluation of expressions?
    • Alternatively, what's the difference between "=" as used in assignment and comparison?
    • 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"?

XML

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 "nbsp" in the entity reference " " mean?
  3. In XML, what are the built-in entities?
    • Which one is not also in HTML?
  4. In XML, when would you use the "quot" or "apos" entities?

Structure

  1. In XML, what's the difference between well-formed and valid?
  2. In XML, what is a DOCTYPE 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 "<?xml"?
    • What's the difference between a processing instruction and an XML declaration?
    • Bonus question: what's a text declaration?
  5. In XML, what does the encoding declaration indicate?
    • How is it used?
    • 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?
    • If a namespace declaration is on an element, does it apply to the attributes as well?
  5. If an XML document has no namespaces, what does it mean if you add xmlns="xyz" to the top?
  6. What happens if element names have prefixes that aren't in scope? Are they in no namespace?
  7. What namespace bindings are in effect by default?
  8. What's the relationship between a QName and an expanded name?
    • Alternatively, what's the difference between an element or attribute's name, its local name, its prefix, and its namespace?
  9. Can you rebind a prefix that is already in scope?
  10. Can you rebind a prefix to the null namespace?
  11. Can you "undeclare" namespaces (make a prefix no longer be bound at all)?

Processing

  1. What does an XML parser do?
    • Where does it sit in an XML document processing workflow?
    • What about in the XSLT processing workflow?
  2. In XML, what kind of information does the parser read, and what does it report?
    • 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?
    • 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?
    • 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?
    • 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?
    • Is it possible to have any others?
    • What is an example of how you would identify or create an object of each of those types in an XPath expression?
  4. How would you refer to an empty node-set?
  5. Is an empty node-set true or false?
    • What about an XSLT 1.0 result tree fragment?
  6. What is an axis?
    • Name and describe some of them.
  7. What is a node-set? What order are the nodes in?
  8. What is document order?
  9. What is a predicate and what is it for?
  10. What does a predicate that is just a digit (like "[1]") mean?
  11. In XPath 1.0, what does "*" mean? What does it imply about namespaces?
  12. In XPath 1.0, how would you select elements in a non-null namespace?
  13. In XPath 1.0, what does an equality comparison of two node-sets evaluate to?
    • That is, what would "x=y" (without the quotes) mean? What about "1=1"?
  14. In XPath 1.0, what is the difference between "x != y" and "not(x=y)"?
  15. In XPath, how can you determine that node "x" is a member of a node-set "y"?
    • Similarly, how can you determine that two expressions identify the same node?
  16. In XPath, what's the "context"?
  17. What are some of the major differences between XPath 1.0 and 2.0?
    • Which should you use?

XSLT

  1. In XSLT, what's the "context"?
    • How is it different from the XPath context?
  2. In XSLT 1.0, how would you produce XHTML output?
  3. If producing output for modern web browsers, would you opt to produce XHTML 1.0, HTML 4, or HTML5, and why? Which is better?
  4. What's the difference between xsl:param and xsl:variable?
  5. What does xsl:apply-templates do?
  6. What's the difference between xsl:apply-templates and xsl:for-each?
  7. What are template priorities, and when would you override them?
  8. What's the difference between xsl:include and xsl:import?
  9. What's the usefulness of imports?
  10. What happens if two templates match the same node at the same priority and import precedence?
  11. In XSLT, how do you read from different source documents?
    • Can those documents be in any format?
  12. In XSLT, when iterating over nodes, how would you ensure that a separator appears in between the output you generate for each node?
    • How would you go about producing different output for every other node (e.g., alternating table row background colors)?
  13. What methods can you use for grouping?
    • 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?
    • 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?
    • Is there another method you know about? Why would you use one method or the other?
    • What would you do if the nodes were not immediate siblings?
  14. When would you want to use template modes?
  15. In XSLT, what are the "push" and "pull" approaches to processing, and when would you prefer one over the other?
  16. How would you generate a table of contents?
  17. What's the difference between the current node and the context node?
    • When do you use the current() function?
  18. In XSLT, what does xsl:key do, and what would be an example of its use?
    • What does the key() function return?
    • How do you control what documents the key() function looks in?
    • Technical writing bonus: What's wrong with writing "key() function"?
  19. In XSLT, how would you create a variable that is just a string?
    • What if the string needed to contain quotation marks or apostrophes?
  20. In XSLT 1.0, what is a result tree fragment?
  21. In XSLT 1.0, how would you make a variable's value be conditional? What if the variable needed to be a node-set?
  22. In XSLT, what is the "node-set" or "nodeset" extension function?
  23. What is EXSLT?
  24. In XSLT, what is disable-output-escaping?
    • When would you use it?
    • What are its risks?
  25. 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?
  26. What's the difference between an XPath expression and an XSLT pattern?
  27. In XSLT, how would you create output that is identical to the input?
    • Would the output XML really be 100% identical to the input?
    • How would you create output that is identical to the input except for changing all elements named "x" to be named "y"?
  28. In HTML, you can use "&nbsp;" to represent a no-break space. Can you do this in XML too? How?
    • What other representations of no-break space are available, and how are they different from each other?
    • In XSLT, how would you create a no-break space in HTML output?
    • Is it necessary to produce "&nbsp;"?
    • How can you encourage the XSLT processor to emit "&nbsp;", and can this be forced?
  29. In XSLT, how do you embed data in the stylesheet?
  30. In XSLT 1.0, how can you output the current date and time?
  31. In XSLT 1.0, how would you process nodes in sorted order (say, alphanumerically by their string-value)?
    • What if the sort needed to be case-insensitive?
  32. What are some of the major differences between XSLT 1.0 and 2.0?
    • Which should you use?