Best Practice or Urban Legend

Teaching XSLT in the Era of Stack Overflow

XML London 2017

Nic Gibson / nicg@corb.as / @CorbasLtd

What's this all about?

  • Learning & training has changed
  • There is a crisis of authority in training
  • How I was completely wrong on the internet
  • And what that made me think about

The Story…

duty calls
  • Where? stackoverflow.com
  • When? February 2017
  • The crime? Answering questions badly on Stack Overflow

http://bit.ly/2sqACd9

The Question

Extract unique elements from the input XSLT

For example the input is this:


<root>
  <command name="comm1">aa</command>
  <command name="comm2">bb</command>
  <command name="comm3">cc</command>
  <command name="comm3">dd</command>
  <command name="comm2">ee</command>
  <command name="comm1">ff</command>
  <command name="comm5">gg</command>
</root>
          

The desired output is this:

<root>
  <command name="comm1">aa</command>
  <command name="comm2">bb</command>
  <command name="comm3">cc</command>
  <command name="comm5">gg</command>
</root>
            

You can see that at the output, we don't have repeating tags ,the text values are not important here.

The Answer

    
    <xsl:template match="command">
        <xsl:if test="not(
        preceding-sibling::command[@name = current()/@name])">
            <xsl:copy-of select="."/>
        </xsl:if>
    </xsl:template>    
    
                        
    
    <xsl:template 
      match=
      "command[preceding-sibling::command[
      @name = current()/@name]]"/>
                            
                        

The Failure

  • No explanation
  • Not the best answer (but accepted)
  • Led to an argument with no resolution
  • Old references
  • FAQ?

Wounded Pride

  • Is there data to back that up?
  • But Jeni said it…
  • Get some data

Let's Generate Some Data

  • Generate c.17,000 XML docs
  • Vary the number of unique elements
  • Vary the number of duplications
  • Run stylesheets on those and get some timings
  • Run with:
    • Saxon 9.7
    • xsltproc
    • msxsl

Well, That's Not What I Expected

XSLT 1 Summary

A little more detail…

Predicates

XSLT 1 Predicates

A little more detail…

Grouping

XSLT 1 Groups

Learning and Training…

Copying and Pasting from Stack Overflow
  • SO is about Q & A
  • Should it be about teaching?
  • What affect does it have on teaching?

How do People Learn?

How Do You learn a New Skill?

Learning a New Tech

How Would You Solve a Problem?

Solving Specific Problems

Do You Use Sites Such as Stack Overflow?

Do you use SO?

What about the mailing list?

SO vs Mulberry List

What's so Wrong with Stack Overflow?

  • Answers as competition
  • “Me too” syndrome
  • Authority vs Reliability
  • Depth & Context

Reputation, reputation, reputation

SO usage by reputation

Implications

  • Teaching is a Responsibility
  • Answers need Data
  • FAQs and Tutorials must be Obvious
  • In a niche language any the importance of any resource is amplified.

Dubious StudyDon't Believe Everything you Write on the Internet