html5/tools/hv/rnv-1.7.8/tools addr-spec-dsl.rnc,NONE,1.1 addr-spec.rnc,NONE,1.1 arx.conf,NONE,1.1 fo.rnc,NONE,1.1 none.rnc,NONE,1.1 relaxng.rnc,NONE,1.1 rnv.vim,NONE,1.1 rvp.pl,NONE,1.1 rvp.py,NONE,1.1 xck,NONE,1.1 xslt-dsl.rnc,NONE,1.1 xslt.rnc,NONE,1.1

Update of /sources/public/html5/tools/hv/rnv-1.7.8/tools
In directory hutz:/tmp/cvs-serv11387/tools

Added Files:
	addr-spec-dsl.rnc addr-spec.rnc arx.conf fo.rnc none.rnc 
	relaxng.rnc rnv.vim rvp.pl rvp.py xck xslt-dsl.rnc xslt.rnc 
Log Message:
initial add

--- NEW FILE: rvp.py ---
# $Id: rvp.py,v 1.1 2009/08/03 05:32:49 mike Exp $

# embedding sample for RVP, a part of RNV, http://davidashen.net/rnv.html
# code kept simple to show the technique, not to provide a general purpose
# module.
#
# details of the protocol are in a long comment near the start of rvp.c
#

import sys, os, string, re, xml.parsers.expat

global rvpin,rvpout,pat,errors,parser,text,ismixed,prevline,prevcol

# raised by resp if it gets something the module does not understand
class ProtocolError(Exception):
  def __init__(self, value):
    self.value = value
  def __str__(self):
    return repr(self.value)

# run RVP with grammar specified on the command line
def launch():
  global rvpin,rvpout
  inp,out=os.popen2('rvp '+string.join(sys.argv[1:],' '))
  rvpin,rvpout=inp.fileno(),out.fileno() # os.read|os.write will be used

# terminate string with zero, encode in utf-8 and then send to RVP
def send(s):
  os.write(rvpin,s.encode('UTF-8')+'\0')

# receive a zero-terminated response from RVP, zero byte is dropped
def recv():
  s=''
  while 1:
    s=s+os.read(rvpout,16) # 16 is good for ok responses, errors should be rare
    if(s[-1]=='\0'): break # last character in a response is always '\0'
  return s[:-1]

# return current pattern value, and print error message on stderr, if any
def resp():
  global errors,prevline,prevcol
  r=string.split(recv(),' ',3)
  if(r[0]=='ok'): return r[1]
  if(r[0]=='error'):
    errors=1
    if(r[3]!=''): # if the error string is empty, then error
    		  # is occured in erroneous state; don't report
      line,col=parser.ErrorLineNumber,parser.ErrorColumnNumber
      if(line!=prevline or col!=prevcol): # one report per file position
	sys.stderr.write(str(line)+","+str(col)+": "+r[3])
	prevline,prevcol=line,col
    return r[1]
  if(r[0]=='er'):
    errors=1
    return r[1]
  raise ProtocolError,"unexpected response '"+r[0]+"'"

def start_tag_open(cur,name):
  send('start-tag-open '+cur+' '+name)
  return resp()

def attribute(cur,name,val):
  send('attribute '+cur+' '+name+' '+val)
  return resp()

def start_tag_close(cur,name):
  send('start-tag-close '+cur+' '+name)
  return resp()

def end_tag(cur,name):
  send('end-tag '+cur+' '+name)
  return resp()

def textonly(cur,text):
  send('text '+cur+' '+text)
  return resp()

# in mixed content, whitespace is simply discarded, and any
# non-whitespace is equal; but this optimization gives only
# 5% increase in speed at most in practical cases
def mixed(cur,text):
  if(re.search('[^\t\n ]',text)):
    send('mixed '+cur+' .')
    return resp()
  else: return cur

def start(g):
  send('start '+g)
  return resp()

def quit():
  send('quit')
  return resp()

# Expat handlers

# If I remember correctly, Expat has the custom not to concatenate
# text nodes; therefore CharDataHandler just concatenates them into
# text, and then flush_text passes the text to the validator
def flush_text():
  global ismixed,pat,text

  if(ismixed):
    pat=mixed(pat,text)
  else:
    pat=textonly(pat,text)
  text=''

def start_element(name,attrs):
  global ismixed,pat

  ismixed=1
  flush_text()
  pat=start_tag_open(pat,name)
  ismixed=0
  for n,v in attrs.items(): pat=attribute(pat,n,v)
  pat=start_tag_close(pat,name)

def end_element(name):
  global ismixed,pat

  flush_text()
  pat=end_tag(pat,name)
  ismixed=1

def characters(data):
  global text

  text=text+data

# Main

errors=0
launch()
pat=start('0') # that is, start of the first grammar;
	       # multiple grammars can be passed to rvp
parser=xml.parsers.expat.ParserCreate('UTF-8',':') # last colon in the name
                                  # separates local name from namespace URI
parser.StartElementHandler=start_element
parser.EndElementHandler=end_element
parser.CharacterDataHandler=characters

text=''
prevline,prevcol=-1,-1
parser.ParseFile(sys.stdin)

quit() # this stops RVP; many files can be validated with a single RVP
       # running, concurrently or sequentially
sys.exit(errors)

--- NEW FILE: addr-spec.rnc ---
# $Id: addr-spec.rnc,v 1.1 2009/08/03 05:32:49 mike Exp $
# RFC 2822 addr-spec

start=element addr-spec {
  xsd:token {
    pattern=
      "(\(([^\(\)\\]|\\.)*\) )?"
    ~ """([a-zA-Z0-9!#$%&'*+\-/=?\^_`{|}~]+(\.[a-zA-Z0-9!#$%&'*+\-/=?\^_`{|}~]+)*|"([^"\\]|\\.)*")"""
    ~ "@" 
    ~ "([a-zA-Z0-9!#$%&'*+\-/=?\^_`{|}~]+(\.[a-zA-Z0-9!#$%&'*+\-/=?\^_`{|}~]+)*|\[([^\[\]\\]|\\.)*\])"
    ~ "( \(([^\(\)\\]|\\.)*\))?"
    
  }
}


--- NEW FILE: relaxng.rnc ---
# RELAX NG for RELAX NG

# $Id: relaxng.rnc,v 1.1 2009/08/03 05:32:49 mike Exp $

namespace local = ""
default namespace rng = "http://relaxng.org/ns/structure/1.0"

start = pattern
pattern =
  element element {
    (attribute name { xsd:QName }
     | open-name-class),
    common-atts,
    open-patterns
  }
  | element attribute {
      common-atts,
      (attribute name { xsd:QName }
       | open-name-class),
      (other & pattern?)
    }
  | element group { common-atts, open-patterns }
  | element interleave { common-atts, open-patterns }
  | element choice { common-atts, open-patterns }
  | element optional { common-atts, open-patterns }
  | element zeroOrMore { common-atts, open-patterns }
  | element oneOrMore { common-atts, open-patterns }
  | element list { common-atts, open-patterns }
  | element mixed { common-atts, open-patterns }
  | element ref {
      attribute name { xsd:NCName },
      common-atts,
      other
    }
  | element parentRef {
      attribute name { xsd:NCName },
      common-atts,
      other
    }
  | element empty { common-atts, other }
  | element text { common-atts, other }
  | element value {
      attribute type { xsd:NCName }?,
      common-atts,
      text
    }
  | element data {
      attribute type { xsd:NCName },
      common-atts,
      (other
       & (element param {
            attribute name { xsd:NCName },
            common-atts,
            text
          }*,
          element except { common-atts, open-patterns }?))
    }
  | element notAllowed { common-atts, other }
  | element externalRef {
      attribute href { xsd:anyURI },
      common-atts,
      other
    }
  | element grammar { common-atts, grammar-content }
grammar-content =
  other
  & (start-element
     | define-element
     | element div { common-atts, grammar-content }
     | element include {
         attribute href { xsd:anyURI },
         common-atts,
         include-content
       })*
include-content =
  other
  & (start-element
     | define-element
     | element div { common-atts, include-content })*
start-element = element start { combine-att, common-atts, open-pattern }
define-element =
  element define {
    attribute name { xsd:NCName },
    combine-att,
    common-atts,
    open-patterns
  }
combine-att = attribute combine { "choice" | "interleave" }?
open-patterns = other & pattern+
open-pattern = other & pattern
name-class =
  element name { common-atts, xsd:QName }
  | element anyName { common-atts, except-name-class }
  | element nsName { common-atts, except-name-class }
  | element choice { common-atts, open-name-classes }
except-name-class =
  other
  & element except { open-name-classes }?
open-name-classes = other & name-class+
open-name-class = other & name-class
common-atts =
  attribute ns { text }?,
  attribute datatypeLibrary { xsd:anyURI }?,
  attribute * - (rng:* | local:*) { text }*
other =
  element * - rng:* {
    (attribute * { text }
     | text
     | any)*
  }*
any =
  element * {
    (attribute * { text }
     | text
     | any)*
  }

--- NEW FILE: addr-spec-dsl.rnc ---
# $Id: addr-spec-dsl.rnc,v 1.1 2009/08/03 05:32:49 mike Exp $
# RFC 2822 addr-spec

datatypes dsl = "http://davidashen.net/relaxng/scheme-datatypes"

start=element addr-spec {
  dsl:token {
    s-pattern="""
      comment = "\(([^\(\)\\]|\\.)*\)"
      atom = "[a-zA-Z0-9!#$%&'*+\-/=?\^_`{|}~]+"
      atoms = atom "(\." atom ")*"
      person = "\"([^\"\\]|\\.)*\""
      location = "\[([^\[\]\\]|\\.)*\]"
      local-part = "(" atom "|" person ")"
      domain = "(" atoms "|" location ")"
      start = "(" comment " )?" local-part "@" domain "( " comment ")?"
    """
  }
}


--- NEW FILE: xck ---
#!/bin/sh

CONF=/usr/local/share/rng-c/arx.conf

files=$*

if [ -z "$files" ] ; then
  cat > /tmp/xck.$$
  files=/tmp/xck.$$
fi

for x in $files
do
  xx $x | rnv -q `arx $x $CONF`
done
rm /tmp/xck.$$ 2>/dev/null

--- NEW FILE: fo.rnc ---
# This DTD has been developed in order to validate XSL FO documents 
# conformant to XSL Recommendation of October 15, 2001. The namespace 
# prefix is 
# 
#   xmlns:fo="http://www.w3.org/1999/XSL/Format".
# 
# This DTD also makes provision for few extensions to XSL Rec, put 
# into a separate namespace: 
# 
#   xmlns:rx="http://www.renderx.com/XSL/Extensions".
# 
# Please e-mail your comments to Nikolai Grigoriev <grig@renderx.com>
# Converted to Relax NG Compact Syntax using by David Tolpin <dvd@davidashen.net> using Trang, http://relaxng.org/
# 
# © RenderX, 1999-2002. 
#
# *******************************************************************
# 
# This DTD was written in mind to validate testcases for the new XSL FO 
[...1551 lines suppressed...]
multi-properties-attlist &= block-properties
# ===============================================================
# Multi property set. Since these are properties of a
# fo:multi-properties that is considered a block, we accept only
# block properties here.
# ===============================================================
multi-property-set =
  element fo:multi-property-set { multi-property-set-attlist, empty }
multi-property-set-attlist &=
  block-properties,
  attribute active-state {
    "link" | "visited" | "active" | "hover" | "focus"
  }
start = root
any =
  (element * {
     attribute * { text }*,
     any
   }
   | text)*

--- NEW FILE: arx.conf ---
(This appears to be a binary file; contents omitted.)

--- NEW FILE: rnv.vim ---
if exists("current_compiler")
  finish
endif
let current_compiler = "rnv"

let s:cpo_save = &cpo
set cpo-=C

setlocal makeprg=rnv\ -q\ `arx\ %\ /usr/local/share/rng-c/arx.conf`\ %
setlocal errorformat=error\ (%f\\,%l\\,%c):\ %m

let &cpo = s:cpo_save
unlet s:cpo_save

--- NEW FILE: xslt-dsl.rnc ---
# $Id: xslt-dsl.rnc,v 1.1 2009/08/03 05:32:49 mike Exp $

# This file has been modified to use 
#   http://davidashen.net/relaxng/scheme-datatypes
# as the datatypes library; it useful for testing purposes.
#
# This was mostly generated from the syntax summary in the XSLT
# Recommendation (using XSLT of course).

# Issues: this validates extension elements as literal result
# elements, which is overly restrictive.

namespace local = ""
default namespace xsl = "http://www.w3.org/1999/XSL/Transform"
datatypes dsl = "http://davidashen.net/relaxng/scheme-datatypes"

start =
  stylesheet.element
  | transform.element
  | literal-result-element-as-stylesheet
version = "1.0"
top-level-elements.model =
  (top-level-element.category | top-level-extension)*
top-level-extension =
  element * - (xsl:* | local:*) {
    grammar {
      start = any
      any =
        (attribute * { text }
         | text
         | element * { any })*
    }
  }
template.model = (instruction.category | literal-result-element | text)*
literal-result-element-as-stylesheet =
  element * - xsl:* {
    attribute xsl:version { version },
    literal-result-element-no-version.atts,
    template.model
  }
literal-result-element =
  element * - xsl:* { literal-result-element.atts, template.model }
literal-result-element.atts =
  literal-result-element-no-version.atts,
  attribute xsl:version { version }?
literal-result-element-no-version.atts =
  (attribute * - xsl:* { avt.datatype }
   | attribute xsl:extension-element-prefixes { prefixes.datatype }
   | attribute xsl:exclude-result-prefixes { prefixes.datatype }
   | attribute xsl:use-attribute-sets { qnames.datatype })*
top-level-element.category =
  include.element
  | strip-space.element
  | preserve-space.element
  | template.element
  | namespace-alias.element
  | attribute-set.element
  | variable.element
  | param.element
  | key.element
  | decimal-format.element
  | output.element
instruction.category =
  apply-templates.element
  | apply-imports.element
  | call-template.element
  | element.element
  | attribute.element
  | text.element
  | processing-instruction.element
  | comment.element
  | copy.element
  | value-of.element
  | number.element
  | for-each.element
  | if.element
  | choose.element
  | variable.element
  | copy-of.element
  | message.element
  | fallback.element
extension.atts = attribute * - (xsl:* | local:*) { text }*
stylesheet.element = element stylesheet { stylesheet.model }
transform.element = element transform { stylesheet.model }
stylesheet.model =
  extension.atts,
  attribute id { dsl:NCName }?,
  attribute extension-element-prefixes { prefixes.datatype }?,
  attribute exclude-result-prefixes { prefixes.datatype }?,
  attribute version { version },
  (import.element*, top-level-elements.model)
include.element =
  element include {
    extension.atts,
    attribute href { dsl:anyURI }
  }
import.element =
  element import {
    extension.atts,
    attribute href { dsl:anyURI }
  }
strip-space.element =
  element strip-space {
    extension.atts,
    attribute elements { wildcards.datatype }
  }
preserve-space.element =
  element preserve-space {
    extension.atts,
    attribute elements { wildcards.datatype }
  }
template.element =
  element template {
    extension.atts,
    attribute match { pattern.datatype }?,
    attribute name { qname.datatype }?,
    attribute priority { number.datatype }?,
    attribute mode { qname.datatype }?,
    (param.element*, template.model)
  }
apply-templates.element =
  element apply-templates {
    extension.atts,
    attribute select { expression.datatype }?,
    attribute mode { qname.datatype }?,
    (sort.element | with-param.element)*
  }
apply-imports.element = element apply-imports { extension.atts }
call-template.element =
  element call-template {
    extension.atts,
    attribute name { qname.datatype },
    with-param.element*
  }
namespace-alias.element =
  element namespace-alias {
    extension.atts,
    attribute stylesheet-prefix { prefix.datatype },
    attribute result-prefix { prefix.datatype }
  }
element.element =
  element element {
    extension.atts,
    attribute name { qname.datatype | expr-avt.datatype },
    attribute namespace { dsl:anyURI | brace-avt.datatype }?,
    attribute use-attribute-sets { qnames.datatype }?,
    template.model
  }
attribute.element =
  element attribute {
    extension.atts,
    attribute name { qname.datatype | expr-avt.datatype },
    attribute namespace { dsl:anyURI | brace-avt.datatype }?,
    template.model
  }
attribute-set.element =
  element attribute-set {
    extension.atts,
    attribute name { qname.datatype },
    attribute use-attribute-sets { qnames.datatype }?,
    attribute.element*
  }
text.element =
  element text {
    extension.atts,
    attribute disable-output-escaping {
      dsl:string "yes" | dsl:string "no"
    }?,
    text
  }
processing-instruction.element =
  element processing-instruction {
    extension.atts,
    attribute name { dsl:NCName | expr-avt.datatype },
    template.model
  }
comment.element = element comment { extension.atts, template.model }
copy.element =
  element copy {
    extension.atts,
    attribute use-attribute-sets { qnames.datatype }?,
    template.model
  }
value-of.element =
  element value-of {
    extension.atts,
    attribute select { expression.datatype },
    attribute disable-output-escaping {
      dsl:string "yes" | dsl:string "no"
    }?
  }
number.element =
  element number {
    extension.atts,
    attribute level {
      dsl:string "single" | dsl:string "multiple" | dsl:string "any"
    }?,
    attribute count { pattern.datatype }?,
    attribute from { pattern.datatype }?,
    attribute value { expression.datatype }?,
    attribute format { avt.datatype }?,
    attribute lang { dsl:NMTOKEN | expr-avt.datatype }?,
    attribute letter-value {
      dsl:string "alphabetic"
      | dsl:string "traditional"
      | expr-avt.datatype
    }?,
    attribute grouping-separator { char.datatype | expr-avt.datatype }?,
    attribute grouping-size { number.datatype | expr-avt.datatype }?
  }
for-each.element =
  element for-each {
    extension.atts,
    attribute select { expression.datatype },
    (sort.element*, template.model)
  }
if.element =
  element if {
    extension.atts,
    attribute test { expression.datatype },
    template.model
  }
choose.element =
  element choose { extension.atts, (when.element+, otherwise.element?) }
when.element =
  element when {
    extension.atts,
    attribute test { expression.datatype },
    template.model
  }
otherwise.element = element otherwise { extension.atts, template.model }
sort.element =
  element sort {
    extension.atts,
    attribute select { expression.datatype }?,
    attribute lang { dsl:NMTOKEN | expr-avt.datatype }?,
    attribute data-type {
      dsl:string "text"
      | dsl:string "number"
      | qname-but-not-ncname.datatype
      | expr-avt.datatype
    }?,
    attribute order {
      dsl:string "ascending"
      | dsl:string "descending"
      | expr-avt.datatype
    }?,
    attribute case-order {
      dsl:string "upper-first"
      | dsl:string "lower-first"
      | expr-avt.datatype
    }?
  }
variable.element =
  element variable {
    extension.atts,
    attribute name { qname.datatype },
    (attribute select { expression.datatype }
     | template.model)
  }
param.element =
  element param {
    extension.atts,
    attribute name { qname.datatype },
    (attribute select { expression.datatype }
     | template.model)
  }
copy-of.element =
  element copy-of {
    extension.atts,
    attribute select { expression.datatype }
  }
with-param.element =
  element with-param {
    extension.atts,
    attribute name { qname.datatype },
    (attribute select { expression.datatype }
     | template.model)
  }
key.element =
  element key {
    extension.atts,
    attribute name { qname.datatype },
    attribute match { pattern.datatype },
    attribute use { expression.datatype }
  }
decimal-format.element =
  element decimal-format {
    extension.atts,
    attribute name { qname.datatype }?,
    attribute decimal-separator { char.datatype }?,
    attribute grouping-separator { char.datatype }?,
    attribute infinity { text }?,
    attribute minus-sign { char.datatype }?,
    attribute NaN { text }?,
    attribute percent { char.datatype }?,
    attribute per-mille { char.datatype }?,
    attribute zero-digit { char.datatype }?,
    attribute digit { char.datatype }?,
    attribute pattern-separator { char.datatype }?
  }
message.element =
  element message {
    extension.atts,
    attribute terminate { dsl:string "yes" | dsl:string "no" }?,
    template.model
  }
fallback.element = element fallback { extension.atts, template.model }
output.element =
  element output {
    extension.atts,
    attribute method {
      dsl:string "xml"
      | dsl:string "html"
      | dsl:string "text"
      | qname-but-not-ncname.datatype
    }?,
    attribute version { dsl:NMTOKEN }?,
    attribute encoding { text }?,
    attribute omit-xml-declaration {
      dsl:string "yes" | dsl:string "no"
    }?,
    attribute standalone { dsl:string "yes" | dsl:string "no" }?,
    attribute doctype-public { text }?,
    attribute doctype-system { text }?,
    attribute cdata-section-elements { qnames.datatype }?,
    attribute indent { dsl:string "yes" | dsl:string "no" }?,
    attribute media-type { text }?
  }
prefixes.datatype = list { (dsl:NCName | "#default")* }
prefix.datatype = dsl:NCName | "#default"
wildcards.datatype =
  list {
    (dsl:QName
     | dsl:token { pattern = "\*|\i\c*:\*" })*
  }
qname.datatype = dsl:QName
qnames.datatype = list { dsl:QName* }
char.datatype = dsl:string { length = "1" }
number.datatype = dsl:decimal
expression.datatype = text
pattern.datatype = text
qname-but-not-ncname.datatype = dsl:QName { pattern = ".*:.*" }
# An AVT containing at least one expression.
expr-avt.datatype =
  dsl:string {
    pattern =
      """([^\{\}]|\{\{|\}\})*\{([^"'\{\}]|"[^"]*"|'[^']*')+\}([^\{\}]|\{\{|\}\}|\{([^"'\{\}]|"[^"]*"|'[^']*')+\})*"""
  }
# An AVT containing at least one brace; ie where instantiated AVT
# is not the same as the literal AVT.
brace-avt.datatype =
  dsl:string {
    pattern =
      """[^\{\}]*(\{\{|\}\}|\{([^"'\{\}]|"[^"]*"|'[^']*')+\})([^\{\}]|\{\{|\}\}|\{([^"'\{\}]|"[^"]*"|'[^']*')+\})*"""
  }
avt.datatype =
  dsl:string {
    pattern =
      """([^\{\}]|\{\{|\}\}|\{([^"'\{\}]|"[^"]*"|'[^']*')+\})*"""
  }

--- NEW FILE: rvp.pl ---
#!/usr/local/bin/perl
# $Id: rvp.pl,v 1.1 2009/08/03 05:32:49 mike Exp $

# embedding sample for RVP, a part of RNV, http://davidashen.net/rnv.html
# code kept simple to show the technique, not to provide a general purpose
# module.
#
# details of the protocol are in a long comment near the start of rvp.c
#

use FileHandle; use IPC::Open2;
use XML::Parser::Expat;

use strict;

my @RVP=("rvp");

my ($parser,$errors,$prevline,$prevcol); # declared here for use in resp()

# rvp wrapper
$|=1;  # using pipes
$/="\0"; # the zero byte is separator

# write queries to RVPIN, get responses from RVPOUT
open2(\*RVPOUT,\*RVPIN,@RVP,@ARGV);

sub resp {
  $_=<RVPOUT>;
  chop;
  /^ok (\d+).*/ and return $1;
  /^error (\d+) (\d+) (.*)/ and do {
      my ($pat,$msg)=($1,$3);

     # if the message is empty, don't print the message,
     # the error has occured in already erroneous state
      if($msg) {
        my ($line,$col)=($parser->current_line(),$parser->current_column());
	if($line!=$prevline || $col!=$prevcol) {
          printf STDERR "%u,%u: %s\n",$line,$col,$msg;
	  $prevline=$line; $prevcol=$col;
	}
      }
      $errors=1;
      return $pat;
    };
  /^er (\d+).*/ and do {$errors=1; return $1;};
  die "protocol error ($_), stopped ";
}

sub start_tag_open {
  my($cur,$name)=@_;
  syswrite RVPIN,"start-tag-open $cur $name\0";
  return resp();
}

sub attribute {
  my($cur,$name,$val)=@_;
  syswrite RVPIN,"attribute $cur $name $val\0";
  return resp();
}

sub start_tag_close {
  my($cur,$name)=@_;
  syswrite RVPIN,"start-tag-close $cur $name\0";
  return resp();
}

sub end_tag {
  my($cur,$name)=@_;
  syswrite RVPIN,"end-tag $cur $name\0";
  return resp();
}

sub text {
  my($cur,$text)=@_;
  syswrite RVPIN,"text $cur $text\0";
  return resp();
}

# in mixed content, whitespace is simply discarded, and any
# non-whitespace is equal; but this optimization gives only only
# 5% increase in speed at most in practical cases
sub mixed {
  my($cur,$text)=@_;
  if($text=~m/[^\t\n ]/s) {
    syswrite RVPIN,"mixed $cur .\0";
    return resp();
  } else {
    return $cur;
  }
}

sub start {
  my $no=shift @_ or 0;
  syswrite RVPIN,"start $no\0";
  return resp();
}

sub quit {
  syswrite RVPIN,"quit\0";
  return resp();
}

my ($current,$text,$mixed)=(0,"",0);

# Expat handlers

# Expat does not merge cdata into one text node;
# application has to do it explicitely (see characters())
sub flush_text {
  $current=$mixed?mixed($current,$text):text($current,$text);
  $text="";
}

# last colon in a name separates the local name from the URI
sub qname {
   my ($p,$name)=@_;
   return join(':',$p->namespace($name),$name);
}

sub start_element {
  my ($p,$el,%attrs)=@_;

  $mixed=1;
  flush_text();
  $current=start_tag_open($current,qname($p,$el));
  $mixed=0;
  for my $atname (keys %attrs) {
    $current=attribute($current,qname($p,$atname),$attrs{$atname});
  }
  $current=start_tag_close($current,qname($p,$el));
}

sub end_element {
  my ($p,$el)=@_;
  flush_text();
  $current=end_tag($current,qname($p,$el));
  $mixed=1;
}

sub characters {
  my ($p,$chars)=@_;
  $text=$text.$chars;
}

# Main

$errors=0;
$parser=new XML::Parser::Expat(
  Namespaces=>1);

$parser->setHandlers(
  Start=>\&start_element,
  End=>\&end_element,
  Char=>\&characters);

$current=start(0);
$parser->parse(*STDIN);
quit();

exit($errors);

--- NEW FILE: xslt.rnc ---
# $Id: xslt.rnc,v 1.1 2009/08/03 05:32:50 mike Exp $

# This was mostly generated from the syntax summary in the XSLT
# Recommendation (using XSLT of course).

# Issues: this validates extension elements as literal result
# elements, which is overly restrictive.

namespace local = ""
default namespace xsl = "http://www.w3.org/1999/XSL/Transform"

start =
  stylesheet.element
  | transform.element
  | literal-result-element-as-stylesheet
version = "1.0"
top-level-elements.model =
  (top-level-element.category | top-level-extension)*
top-level-extension =
  element * - (xsl:* | local:*) {
    grammar {
      start = any
      any =
        (attribute * { text }
         | text
         | element * { any })*
    }
  }
template.model = (instruction.category | literal-result-element | text)*
literal-result-element-as-stylesheet =
  element * - xsl:* {
    attribute xsl:version { version },
    literal-result-element-no-version.atts,
    template.model
  }
literal-result-element =
  element * - xsl:* { literal-result-element.atts, template.model }
literal-result-element.atts =
  literal-result-element-no-version.atts,
  attribute xsl:version { version }?
literal-result-element-no-version.atts =
  (attribute * - xsl:* { avt.datatype }
   | attribute xsl:extension-element-prefixes { prefixes.datatype }
   | attribute xsl:exclude-result-prefixes { prefixes.datatype }
   | attribute xsl:use-attribute-sets { qnames.datatype })*
top-level-element.category =
  include.element
  | strip-space.element
  | preserve-space.element
  | template.element
  | namespace-alias.element
  | attribute-set.element
  | variable.element
  | param.element
  | key.element
  | decimal-format.element
  | output.element
instruction.category =
  apply-templates.element
  | apply-imports.element
  | call-template.element
  | element.element
  | attribute.element
  | text.element
  | processing-instruction.element
  | comment.element
  | copy.element
  | value-of.element
  | number.element
  | for-each.element
  | if.element
  | choose.element
  | variable.element
  | copy-of.element
  | message.element
  | fallback.element
extension.atts = attribute * - (xsl:* | local:*) { text }*
stylesheet.element = element stylesheet { stylesheet.model }
transform.element = element transform { stylesheet.model }
stylesheet.model =
  extension.atts,
  attribute id { xsd:NCName }?,
  attribute extension-element-prefixes { prefixes.datatype }?,
  attribute exclude-result-prefixes { prefixes.datatype }?,
  attribute version { version },
  (import.element*, top-level-elements.model)
include.element =
  element include {
    extension.atts,
    attribute href { xsd:anyURI }
  }
import.element =
  element import {
    extension.atts,
    attribute href { xsd:anyURI }
  }
strip-space.element =
  element strip-space {
    extension.atts,
    attribute elements { wildcards.datatype }
  }
preserve-space.element =
  element preserve-space {
    extension.atts,
    attribute elements { wildcards.datatype }
  }
template.element =
  element template {
    extension.atts,
    attribute match { pattern.datatype }?,
    attribute name { qname.datatype }?,
    attribute priority { number.datatype }?,
    attribute mode { qname.datatype }?,
    (param.element*, template.model)
  }
apply-templates.element =
  element apply-templates {
    extension.atts,
    attribute select { expression.datatype }?,
    attribute mode { qname.datatype }?,
    (sort.element | with-param.element)*
  }
apply-imports.element = element apply-imports { extension.atts }
call-template.element =
  element call-template {
    extension.atts,
    attribute name { qname.datatype },
    with-param.element*
  }
namespace-alias.element =
  element namespace-alias {
    extension.atts,
    attribute stylesheet-prefix { prefix.datatype },
    attribute result-prefix { prefix.datatype }
  }
element.element =
  element element {
    extension.atts,
    attribute name { qname.datatype | expr-avt.datatype },
    attribute namespace { xsd:anyURI | brace-avt.datatype }?,
    attribute use-attribute-sets { qnames.datatype }?,
    template.model
  }
attribute.element =
  element attribute {
    extension.atts,
    attribute name { qname.datatype | expr-avt.datatype },
    attribute namespace { xsd:anyURI | brace-avt.datatype }?,
    template.model
  }
attribute-set.element =
  element attribute-set {
    extension.atts,
    attribute name { qname.datatype },
    attribute use-attribute-sets { qnames.datatype }?,
    attribute.element*
  }
text.element =
  element text {
    extension.atts,
    attribute disable-output-escaping {
      xsd:string "yes" | xsd:string "no"
    }?,
    text
  }
processing-instruction.element =
  element processing-instruction {
    extension.atts,
    attribute name { xsd:NCName | expr-avt.datatype },
    template.model
  }
comment.element = element comment { extension.atts, template.model }
copy.element =
  element copy {
    extension.atts,
    attribute use-attribute-sets { qnames.datatype }?,
    template.model
  }
value-of.element =
  element value-of {
    extension.atts,
    attribute select { expression.datatype },
    attribute disable-output-escaping {
      xsd:string "yes" | xsd:string "no"
    }?
  }
number.element =
  element number {
    extension.atts,
    attribute level {
      xsd:string "single" | xsd:string "multiple" | xsd:string "any"
    }?,
    attribute count { pattern.datatype }?,
    attribute from { pattern.datatype }?,
    attribute value { expression.datatype }?,
    attribute format { avt.datatype }?,
    attribute lang { xsd:NMTOKEN | expr-avt.datatype }?,
    attribute letter-value {
      xsd:string "alphabetic"
      | xsd:string "traditional"
      | expr-avt.datatype
    }?,
    attribute grouping-separator { char.datatype | expr-avt.datatype }?,
    attribute grouping-size { number.datatype | expr-avt.datatype }?
  }
for-each.element =
  element for-each {
    extension.atts,
    attribute select { expression.datatype },
    (sort.element*, template.model)
  }
if.element =
  element if {
    extension.atts,
    attribute test { expression.datatype },
    template.model
  }
choose.element =
  element choose { extension.atts, (when.element+, otherwise.element?) }
when.element =
  element when {
    extension.atts,
    attribute test { expression.datatype },
    template.model
  }
otherwise.element = element otherwise { extension.atts, template.model }
sort.element =
  element sort {
    extension.atts,
    attribute select { expression.datatype }?,
    attribute lang { xsd:NMTOKEN | expr-avt.datatype }?,
    attribute data-type {
      xsd:string "text"
      | xsd:string "number"
      | qname-but-not-ncname.datatype
      | expr-avt.datatype
    }?,
    attribute order {
      xsd:string "ascending"
      | xsd:string "descending"
      | expr-avt.datatype
    }?,
    attribute case-order {
      xsd:string "upper-first"
      | xsd:string "lower-first"
      | expr-avt.datatype
    }?
  }
variable.element =
  element variable {
    extension.atts,
    attribute name { qname.datatype },
    (attribute select { expression.datatype }
     | template.model)
  }
param.element =
  element param {
    extension.atts,
    attribute name { qname.datatype },
    (attribute select { expression.datatype }
     | template.model)
  }
copy-of.element =
  element copy-of {
    extension.atts,
    attribute select { expression.datatype }
  }
with-param.element =
  element with-param {
    extension.atts,
    attribute name { qname.datatype },
    (attribute select { expression.datatype }
     | template.model)
  }
key.element =
  element key {
    extension.atts,
    attribute name { qname.datatype },
    attribute match { pattern.datatype },
    attribute use { expression.datatype }
  }
decimal-format.element =
  element decimal-format {
    extension.atts,
    attribute name { qname.datatype }?,
    attribute decimal-separator { char.datatype }?,
    attribute grouping-separator { char.datatype }?,
    attribute infinity { text }?,
    attribute minus-sign { char.datatype }?,
    attribute NaN { text }?,
    attribute percent { char.datatype }?,
    attribute per-mille { char.datatype }?,
    attribute zero-digit { char.datatype }?,
    attribute digit { char.datatype }?,
    attribute pattern-separator { char.datatype }?
  }
message.element =
  element message {
    extension.atts,
    attribute terminate { xsd:string "yes" | xsd:string "no" }?,
    template.model
  }
fallback.element = element fallback { extension.atts, template.model }
output.element =
  element output {
    extension.atts,
    attribute method {
      xsd:string "xml"
      | xsd:string "html"
      | xsd:string "text"
      | qname-but-not-ncname.datatype
    }?,
    attribute version { xsd:NMTOKEN }?,
    attribute encoding { text }?,
    attribute omit-xml-declaration {
      xsd:string "yes" | xsd:string "no"
    }?,
    attribute standalone { xsd:string "yes" | xsd:string "no" }?,
    attribute doctype-public { text }?,
    attribute doctype-system { text }?,
    attribute cdata-section-elements { qnames.datatype }?,
    attribute indent { xsd:string "yes" | xsd:string "no" }?,
    attribute media-type { text }?
  }
prefixes.datatype = list { (xsd:NCName | "#default")* }
prefix.datatype = xsd:NCName | "#default"
wildcards.datatype =
  list {
    (xsd:QName
     | xsd:token { pattern = "\*|\i\c*:\*" })*
  }
qname.datatype = xsd:QName
qnames.datatype = list { xsd:QName* }
char.datatype = xsd:string { length = "1" }
number.datatype = xsd:decimal
expression.datatype = text
pattern.datatype = text
qname-but-not-ncname.datatype = xsd:QName { pattern = ".*:.*" }
# An AVT containing at least one expression.
expr-avt.datatype =
  xsd:string {
    pattern =
      """([^\{\}]|\{\{|\}\})*\{([^"'\{\}]|"[^"]*"|'[^']*')+\}([^\{\}]|\{\{|\}\}|\{([^"'\{\}]|"[^"]*"|'[^']*')+\})*"""
  }
# An AVT containing at least one brace; ie where instantiated AVT
# is not the same as the literal AVT.
brace-avt.datatype =
  xsd:string {
    pattern =
      """[^\{\}]*(\{\{|\}\}|\{([^"'\{\}]|"[^"]*"|'[^']*')+\})([^\{\}]|\{\{|\}\}|\{([^"'\{\}]|"[^"]*"|'[^']*')+\})*"""
  }
avt.datatype =
  xsd:string {
    pattern =
      """([^\{\}]|\{\{|\}\}|\{([^"'\{\}]|"[^"]*"|'[^']*')+\})*"""
  }

--- NEW FILE: none.rnc ---
start = notAllowed

Received on Monday, 3 August 2009 05:33:03 UTC