Skip to content

Commit

Permalink
Fix typos
Browse files Browse the repository at this point in the history
  • Loading branch information
kianmeng committed Sep 14, 2021
1 parent 19883e0 commit 0099307
Show file tree
Hide file tree
Showing 23 changed files with 68 additions and 68 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ The output can be interpreted as a structure built from Erlang records. The
definition of these records can either be generated by
erlsom:write_xsd_hrl_file/3, or you can define them yourself (or a combination:
you can run write_xsd_hrl_file and change a few fieldnames and add some
defaults). An extract of the .hrl file genrated by write_xsd_hrl_file/3:
defaults). An extract of the .hrl file generated by write_xsd_hrl_file/3:

```erlang
-record('USAddress', {anyAttribs :: anyAttribs(),
Expand Down
4 changes: 2 additions & 2 deletions examples/complex_form/erlsom_complex_form.erl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
%%% translate XML to the output format used by XMERL.
%%% The output is not complete: some fields in the XMERL output records
%%% are not populated. But is it enough to use the XPATH fucntions (at
%%% are not populated. But is it enough to use the XPATH functions (at
%%% least for the examples that I tried).
%%%
%%% Note: this hasn't been tested properly. See it as an example of how
Expand All @@ -17,7 +17,7 @@

-include_lib("erlsom/src/erlsom_sax.hrl").

%% The record defintions below are copied from xmerl hrl files!
%% The record definitions below are copied from xmerl hrl files!
%% XML Element
%% content = [#xmlElement()|#xmlText()|#xmlPI()|#xmlComment()|#xmlDecl()]
-record(xmlElement,{
Expand Down
2 changes: 1 addition & 1 deletion examples/erlsom_sax_example/sax_example.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<?TARGET This is a programming instruction ?>

<!-- DTD is ingored, except for the entities !-->
<!-- DTD is ignored, except for the entities !-->
<!DOCTYPE aDTD [
<!ELEMENT anElement (#PCDATA)>
<!ENTITY zz 'entity' >
Expand Down
6 changes: 3 additions & 3 deletions make-release
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
set -x
. ./vsn.mk

echo tagging and packing release ${ERLSOM_VSN}
echo tagging and packing release ${ERLSOM_VSN}

CVS_RSH=ssh
Y=`echo ${ERLSOM_VSN} | sed 's/\./-/g'`
Expand All @@ -18,7 +18,7 @@ rm -rf erlsom-0.0.1 2> /dev/null

cvs tag -F erlsom-${Y}

rm -rf tmp
rm -rf tmp
mkdir tmp

cvs export -d tmp -r erlsom-$Y .
Expand All @@ -30,7 +30,7 @@ mv erlsom erlsom-${ERLSOM_VSN}
tar cfz erlsom-${ERLSOM_VSN}.tar.gz erlsom-${ERLSOM_VSN}


echo new release resides in `pwd`/erlsom-${ERLSOM_VSN}.tar.gz
echo new release resides in `pwd`/erlsom-${ERLSOM_VSN}.tar.gz



2 changes: 1 addition & 1 deletion src/erlsom.erl
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ write(Struct, Model, Options) ->
%% description of the events
%% - State - a term()
%%
%% EventFun should return State, a term() that wil be passed back to
%% EventFun should return State, a term() that will be passed back to
%% the next invocation of EventFun.
%%
%% Options - [Option]
Expand Down
12 changes: 6 additions & 6 deletions src/erlsom_compile.erl
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
%% - special treatment is necessary for choices where (some or all)
%% alternatives have the same type: otherwise it will not be possible
%% to recognise from the result which alternative was selected. For
%% the moment this is only implented for 'text' alternatives.
%% the moment this is only implemented for 'text' alternatives.

%% Ideally it should also take care of:
%% - attribute groups
Expand Down Expand Up @@ -81,7 +81,7 @@
%% with multiple XSDs).
imported = [], %% a list of imported namespaces, to prevent
%% getting into a loop when there are circular
%% refernces.
%% references.
path = []}). %% path


Expand Down Expand Up @@ -234,7 +234,7 @@ compile_parsed_xsd(ParsedXsd, Prefix, Namespaces, IncludeFun, IncludeDirs, Inclu
end,
ImportedNs = [Uri || {Uri, _} <- AlreadyImported],
%% Here we are introducing #ns{} records with no value for efd. They
%% will be removed later on... (clean_up fucntion, see below).
%% will be removed later on... (clean_up function, see below).
ImportedNsMapping = [#ns{prefix = P, uri = U} || {U, P} <- AlreadyImported],
%ToBeImportedNsMapping = [#ns{prefix = P, uri = U} || {U, P, _} <- IncludeFiles],
Acc = #p1acc{tns = TargetNs,
Expand Down Expand Up @@ -273,7 +273,7 @@ clean_up(Namespaces) ->
%% -record(schemaType, {targetNamespace, elementFormDefault, elements}).
transform(#schemaType{elements=Elements, imports=Impts},
Acc = #p1acc{}) ->
%% transorm element and types etc.
%% transform element and types etc.
%% in TransformedTypes the top-level types have to be recognisable somehow.
Acc2 = processImports(Impts, Acc),
transformTypes(Elements, Acc2).
Expand Down Expand Up @@ -534,7 +534,7 @@ transformTypes([#globalComplexTypeType{name=Name, model=Model, attributes=Attrib

%%-record(globalSimpleTypeType, {name, annotation, model}).
%% TODO: better would be to avoid getting the 'any' stuff in the
%% translation of the XSD alltogether.
%% translation of the XSD altogether.
%% transformTypes([#globalSimpleTypeType{name=Name, model=undefined}| Tail],
transformTypes([#globalSimpleTypeType{name=Name}| Tail],
Acc = #p1acc{tps = ResultSoFar, nsp = Prefix}) ->
Expand Down Expand Up @@ -777,7 +777,7 @@ findAnyAlternative(Alternatives) ->
{true, AnyAlternative}
end.

%% for now only consider elements that are truely wildcards, because they seem
%% for now only consider elements that are truly wildcards, because they seem
%% to be the most common type and they are the easiest to deal with.
isAny(#alt{tag = '#any', anyInfo = #anyInfo{prCont = "lax", ns = "##any"}}) ->
true;
Expand Down
2 changes: 1 addition & 1 deletion src/erlsom_compile.hrl
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
strict = false :: boolean(), %% enforce additional type checks/conversions
include_any_attrs = false, %% if true, the second element in the result
%% types will be used for
%% atributes that were not explicitly declared
%% attributes that were not explicitly declared
value_fun %% Function that is called after the parsing
%% of a complex type (resulting in creation of a
%% record) has been created. Can be used
Expand Down
8 changes: 4 additions & 4 deletions src/erlsom_lib.erl
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ translateType(String, true) ->
{integer, negativeInteger};
"float" ->
float;
% no disctinction between double and float - both are mapped to
% no distinction between double and float - both are mapped to
% erlang float, no chcecks on size will be performed
"double" ->
float;
Expand Down Expand Up @@ -468,7 +468,7 @@ makeTypeRefAtom(Qname, Namespaces) ->
end.

%% makeTypeRef creates a reference to a type. This can either be a type
%% defined in the XSD (or an imorted XSD), or a predefined type (like
%% defined in the XSD (or an imported XSD), or a predefined type (like
%% xsd:string).
%% For the predefined types special codes are returned ({'#PCDATA', ...}).
%% input is a qname.
Expand All @@ -480,7 +480,7 @@ makeTypeRefAtom(Qname, Namespaces) ->

%% TODO: should return an atom (or {'PCDATA', ...})?
makeTypeRef(undefined, _, _) ->
%% the 'ur-type': any type (and any attibute).
%% the 'ur-type': any type (and any attribute).
{'#PCDATA', 'char'};

makeTypeRef(Qname = #qname{uri = NS, localPart = Local}, Namespaces, Strict) ->
Expand Down Expand Up @@ -571,7 +571,7 @@ makeTag(NameInXsd, #schemaInfo{elementFormDefault="qualified", targetNamespace=T
end;

makeTag(NameInXsd, _SchemaInfo) ->
%% defaultElementForm = unqualified, do not add the prefix (TODO: exept for global elements and types).
%% defaultElementForm = unqualified, do not add the prefix (TODO: except for global elements and types).
NameInXsd.

listLength(undefined) -> 0;
Expand Down
22 changes: 11 additions & 11 deletions src/erlsom_parse.erl
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
%% translate XML (that follows a certain schema - grammar) to a
%% predefined structure (a set of linked records).
%%
%% The XSD is translated to a stucture (called the 'Model'in the code below)
%% The XSD is translated to a structure (called the 'Model'in the code below)
%% that drives the parser, the parser self is generic.
%%
%% The main function is a callback that will be called by the SAX parser.
Expand Down Expand Up @@ -93,7 +93,7 @@
%% Each Alternative is of the form {Tag, TypeReference, MinOccurs, MaxOccurs,
%% RealElement}.
%% - Tag is generally the tag of the element. In case of a 'choice', the
%% combination of the Tag and the next event determines which altenative is
%% combination of the Tag and the next event determines which alternative is
%% selected. Tag can also be '#text', in which case we expect a 'character'
%% event.
%% - TypeReference is either a reference to a Type (a TypeName), or a tuple
Expand Down Expand Up @@ -541,7 +541,7 @@ stateMachine(Event, State = #state{currentState = #altState{name=Name, type=Type
%% check on MaxOccurs
if %%{
Max /= unbound, Count >= Max ->
%% debug("But we have already recieved this event the maximum number of times"),
%% debug("But we have already received this event the maximum number of times"),
%% pop.
{NewCurrentState, Acc2} = pop(lists:reverse(Acc), Head, VFun, ValueAcc),
NewState = State#state{currentState = NewCurrentState,
Expand All @@ -560,7 +560,7 @@ stateMachine(Event, State = #state{currentState = #altState{name=Name, type=Type
resultSoFar = [State#state.currentState | State#state.resultSoFar]};
_Else ->
%% not text: a complex type.
%% look for the type discription
%% look for the type description
%% debug("Not text: a complex type"),
TypeDef = findType(Real, Type, Types, Attributes, TypeHierarchy, Namespaces, NamespaceMapping),
%% #type{els = Elements, atts = ListOfAttributes, nr = NrOfElements} = TypeDef,
Expand Down Expand Up @@ -787,7 +787,7 @@ stateMachine(Event, State = #state{currentState = #cs{re = RemainingElements,
%% debug("This is a valid alternative"),
if
MaxOccurs /= unbound, ReceivedSoFar >= MaxOccurs ->
%% debug("But we have already recieved this event the maximum number of times"),
%% debug("But we have already received this event the maximum number of times"),
%% move on
NewState = State#state{currentState = #cs{re = NextElements,
sf = 0,
Expand Down Expand Up @@ -821,7 +821,7 @@ stateMachine(Event, State = #state{currentState = #cs{re = RemainingElements,
end;
_Else ->
%% not text: a complex type.
%% look for the type discription
%% look for the type description
%% debug("Not text: a complex type"),
%% Look for xsi:type attribute
TypeDef = findType(RealElement2, Type, Types, Attributes, TypeHierarchy, Namespaces, NamespaceMapping),
Expand Down Expand Up @@ -990,13 +990,13 @@ stateMachine(Event, State = #state{currentState = #cs{re = RemainingElements,
%% debug("odd case"),
%% TODO: this seems to be a bit odd? What is this is a reference to a group?
%% a helper element for this text
%% look for the type discription
%% look for the type description
TypeDef = erlsom_lib:findType(Type, Types),
%% create new record for this element
%% (can't have any attributes)
NewRecord = newRecord(TypeDef, StoreAnyAttr),
%% push the current status, create a new level in the state machine
%% (we know that this is a helperElement, therfore RealElement = false)
%% (we know that this is a helperElement, therefore RealElement = false)
NewState = State#state{currentState = #cs{re = TypeDef#type.els,
sf = 0,
er = NewRecord,
Expand Down Expand Up @@ -1087,7 +1087,7 @@ stateMachine(Event, State = #state{currentState = #all{re = RemainingElements,
end;
_Else ->
%% not text: a complex type.
%% look for the type discription
%% look for the type description
%% Look for xsi:type attribute
TypeDef = findType(RealElement, Type, Types, Attributes, TypeHierarchy, Namespaces, NamespaceMapping),
#type{els = Elements, tp = Tp} = TypeDef,
Expand Down Expand Up @@ -1127,7 +1127,7 @@ stateMachine(Event, State = #state{currentState = #all{re = RemainingElements,
end;

{characters, Characters} ->
%% should be be extended to deal with mixed alements, or wit simple elements with attributes?
%% should be be extended to deal with mixed alements, or with simple elements with attributes?
%% not sure...
throw({error,
pp("Unexpected characters event in All: ~s", [Characters])});
Expand Down Expand Up @@ -1478,7 +1478,7 @@ printResultSoFar([_H | T], Acc) ->
%% loop go through the list of elements, checking whether the
%% tag occurs as an alternative in any one of them.
%% return the alternative and remove this element from the list of elements.
%% if the elemnt is not found, return false
%% if the element is not found, return false
findTagInElements(Tag, Elements) ->
findTagInElements(Tag, Elements, []).
findTagInElements(_Tag, [], _) -> false;
Expand Down
2 changes: 1 addition & 1 deletion src/erlsom_parse.hrl
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
mn = 1, mx = 1, mxd = false, %% mn & mx are only used by erlsom_compile
typeName}). %% typeName is the 'real' name, to be used in xsi:type attributes
%% for derived types. The 'nm' field is actually a key, which may
%% include an additional prefix to differntiate between elements, types
%% include an additional prefix to differentiate between elements, types
%% and groups.
-record(el, {alts, mn = 1, mx = 1, nillable,
nr %% nr is actually the position of the value in the
Expand Down
2 changes: 1 addition & 1 deletion src/erlsom_parseXsd.erl
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ xsdModel(Namespaces) ->
nr = 3},

%% -record(simpleContentType, {annotation, model}).
%% simpleContent - extension can contain attibutes, so we have to parse
%% simpleContent - extension can contain attributes, so we have to parse
%% one additional level.
#type{nm = simpleContentType,
anyAttr = AnyAttr,
Expand Down
6 changes: 3 additions & 3 deletions src/erlsom_pass2.erl
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ secondPass(IntermediateStruct,
Types2 = pass3(Types1, Info),
Types3 = pass4(Types2, Info),
DocType = make_Document(GlobalElements, [], Info),
%% fiddle a bit more - replace refernces in the _document that point
%% fiddle a bit more - replace references in the _document that point
%% to unknown types by {#PCDATA, ...}, assuming that they point to
%% simple types that are no longer visible. Even if that assumption
%% would be wrong, it wouldn't have worked otherwise either, so it won't
Expand Down Expand Up @@ -377,7 +377,7 @@ seqOrAll(all) -> all;
seqOrAll(_) -> sequence.

%% purpose of 'Count' is to make sure that we don't get into an infinite loop in case
%% of circular refernces in attributeGroups
%% of circular references in attributeGroups
translateAttributes(_, _Acc, _Pos, _Info, 10) ->
throw({error, "circular reference in attribute group?"});
translateAttributes(undefined, _Acc, _Pos, _Info, _Count) ->
Expand Down Expand Up @@ -430,7 +430,7 @@ translateAlternatives([], Acc, _Types) ->
%% -record(alternative, {tag, type, real, min, max}).
%% Each Alternative is of the form {Tag, TypeReference, RealElement, min, max}.
%% - Tag is generally the tag of the element. In case of a 'choice', the
%% combination of the Tag and the next event determines which altenative is
%% combination of the Tag and the next event determines which alternative is
%% selected. Tag can also be '#text', in which case we expect a 'character'
%% event.
%% - TypeReference is either a reference to a Type (a TypeName), or a tuple
Expand Down
4 changes: 2 additions & 2 deletions src/erlsom_sax.hrl
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
current_entity = '__top',
namespaces = [],
endtags = [],
output, %% determines the encoding of text and atttribute values
output, %% determines the encoding of text and attribute values
expand_entities = true, %% if false, user defined entities will
%% be ignored in the DTD, and use of entities
%% will fail.
Expand Down Expand Up @@ -68,7 +68,7 @@
-define(is_namestart_char(C),
C > 96, C < 123; C > 64, C < 91; C =:= $_).

-define(is_namestart_char2(C), %% also for characters <> 7 bit asscii
-define(is_namestart_char2(C), %% also for characters <> 7 bit ascii
C > 96, C < 123; C > 64, C < 91; C =:= $_;
C > 191, C =/= 215, C =/= 247). %% this check is far from complete!

Expand Down
8 changes: 4 additions & 4 deletions src/erlsom_sax_latin1.erl
Original file line number Diff line number Diff line change
Expand Up @@ -626,7 +626,7 @@ parseStartTag(Tail, State) ->
parseTagName(?STR1_T(Char, Tail), State)
when ?is_namestart_char(Char) ->
%% this should differentiate between 'with namespaces'and 'without'
%% for the moment the assumption is 'with', therfore a name cannot
%% for the moment the assumption is 'with', therefore a name cannot
%% start with a ':'.
parseTagName([Char], Tail, State);
parseTagName(?EMPTY, State) ->
Expand Down Expand Up @@ -1025,8 +1025,8 @@ parseTextNoIgnoreBinary(Head, Tail, State) ->
EncodedChar = erlsom_ucs:char_to_utf8(Char),
parseTextNoIgnoreBinary(<<Head/binary, EncodedChar/binary>>, Tail2, State2).

%% entity refernces in attribute values differ fundamentally from
%% refernces in elements and in entity definitions
%% entity references in attribute values differ fundamentally from
%% references in elements and in entity definitions
%% Context can be: element, attribute, definition
parseReference(Head, Context, ?STR1_T($;, Tail), State) ->
translateReference(lists:reverse(Head), Context, Tail, State);
Expand All @@ -1044,7 +1044,7 @@ parseReference(Head, Context, Tail, State) ->
%% other entities are added to the tail (they still have to be parsed).
%% The problem here is that we have to make sure that we don't get into an infinite
%% loop. This solved as follows:
%% We proceed by parsing only the entity (while registring in the state that we
%% We proceed by parsing only the entity (while registering in the state that we
%% are parsing this particular entity). However, we replace the continuation function
%% by something that simply returns (in stead of calling the function that it was
%% working on recursively). We then proceed.
Expand Down
8 changes: 4 additions & 4 deletions src/erlsom_sax_latin9.erl
Original file line number Diff line number Diff line change
Expand Up @@ -626,7 +626,7 @@ parseStartTag(Tail, State) ->
parseTagName(?STR1_T(Char, Tail), State)
when ?is_namestart_char(Char) ->
%% this should differentiate between 'with namespaces'and 'without'
%% for the moment the assumption is 'with', therfore a name cannot
%% for the moment the assumption is 'with', therefore a name cannot
%% start with a ':'.
parseTagName([Char], Tail, State);
parseTagName(?EMPTY, State) ->
Expand Down Expand Up @@ -1025,8 +1025,8 @@ parseTextNoIgnoreBinary(Head, Tail, State) ->
EncodedChar = erlsom_ucs:char_to_utf8(Char),
parseTextNoIgnoreBinary(<<Head/binary, EncodedChar/binary>>, Tail2, State2).

%% entity refernces in attribute values differ fundamentally from
%% refernces in elements and in entity definitions
%% entity references in attribute values differ fundamentally from
%% references in elements and in entity definitions
%% Context can be: element, attribute, definition
parseReference(Head, Context, ?STR1_T($;, Tail), State) ->
translateReference(lists:reverse(Head), Context, Tail, State);
Expand All @@ -1044,7 +1044,7 @@ parseReference(Head, Context, Tail, State) ->
%% other entities are added to the tail (they still have to be parsed).
%% The problem here is that we have to make sure that we don't get into an infinite
%% loop. This solved as follows:
%% We proceed by parsing only the entity (while registring in the state that we
%% We proceed by parsing only the entity (while registering in the state that we
%% are parsing this particular entity). However, we replace the continuation function
%% by something that simply returns (in stead of calling the function that it was
%% working on recursively). We then proceed.
Expand Down
Loading

0 comments on commit 0099307

Please sign in to comment.