       when 'choice' then new Choice children[0], children[1]
       when 'group' then new Group children[0], children[1]
       when 'interleave' then new Interleave children[0], children[1]
-      when "anyName" then new AnyName node, children[0]
-      when "nsName" then new NsName node, children[0]
-      when "name" then new Name node, children[0]
+      when "anyName" then new AnyName children[0]
+      when "nsName" then new NsName _getAttr(node, "ns"), children[0]
+      when "name" then new Name _getAttr(node, "ns"), children[0]
       when "choice" then new Choice children[0], children[1]
       when 'except' then getPattern children[0]
       when 'param' then new Param _getAttr(node, "name"), children[0]
       else
         throw new RNGException("can't parse pattern for #{node.local}")
-    foo
+    pattern
 
 
   class RNGException extends Error

  class NameClass

  class AnyName extends NameClass
    constructor: (nameClassNode, exceptPattern) ->
      @except = getPattern exceptPattern
    toString: =>
      if @except instanceof NotAllowed

    toString: =>
      "#{@name} = #{@pattern}"

  { _getAttr, getPattern,
    AnyName, Attribute,
    Choice, Context,
    Data, Datatype, Define,
    Empty, Element,
    Group,
    Interleave,
    List,
    MissingContent,
    Name, NameClass, NotAllowed, NsName,
    OneOrMore,
    Param, Pattern,
    Ref,
    Text,
    Value
  }
