Skip to content

Commit

Permalink
wcml: trim elementtype, *id and *ref args
Browse files Browse the repository at this point in the history
The CML schmea prohibits white space in CML id and
ref attributes (which should not be confused with
the XML id and ref attributes - they have different
syntax and semantics) as well as element names.
While it is not easy to check
whitespace in all cases one easy win is possible,
remove any trailing whitespace. This patch does this
where possible using trim. This cannot be done for
all cases without hacking around with the general
case m4 macros - which are used by other FoX
modules.

Note that if this patch changes the behviour of any
application the application was producing invalid
CML. No test cases needed changing for this to pass.
  • Loading branch information
andreww committed Aug 13, 2012
1 parent 5e4725a commit 282b2bc
Show file tree
Hide file tree
Showing 7 changed files with 71 additions and 71 deletions.
24 changes: 12 additions & 12 deletions wcml/m_wcml_geometry.F90
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ subroutine cmlAddLength_sp(xf, id, atomRef1, atomRef2, length, fmt)

#ifndef DUMMYLIB
call xml_NewElement(xf, "length")
call xml_AddAttribute(xf, "id", id)
call xml_AddAttribute(xf, "atomRefs2", atomRef1//" "//atomRef2)
call xml_AddAttribute(xf, "id", trim(id))
call xml_AddAttribute(xf, "atomRefs2", trim(atomRef1)//" "//trim(atomRef2))
call xml_AddCharacters(xf, length, fmt)
call xml_EndElement(xf, "length")
#endif
Expand All @@ -64,8 +64,8 @@ subroutine cmlAddAngle_sp(xf, id, atomRef1, atomRef2, atomRef3, angle, fmt)

#ifndef DUMMYLIB
call xml_NewElement(xf, "angle")
call xml_AddAttribute(xf, "id", id)
call xml_AddAttribute(xf, "atomRefs3", atomRef1//" "//atomRef2//" "//atomRef3)
call xml_AddAttribute(xf, "id", trim(id))
call xml_AddAttribute(xf, "atomRefs3", trim(atomRef1)//" "//trim(atomRef2)//" "//trim(atomRef3))
call xml_AddCharacters(xf, angle, fmt)
call xml_EndElement(xf, "angle")
#endif
Expand All @@ -84,9 +84,9 @@ subroutine cmlAddTorsion_sp(xf, id, atomRef1, atomRef2, atomRef3, atomRef4, tors

#ifndef DUMMYLIB
call xml_NewElement(xf, "torsion")
call xml_AddAttribute(xf, "id", id)
call xml_AddAttribute(xf, "id", trim(id))
call xml_AddAttribute(xf, "atomRefs4", &
atomRef1//" "//atomRef2//" "//atomRef3//" "//atomRef4)
trim(atomRef1)//" "//trim(atomRef2)//" "//trim(atomRef3)//" "//trim(atomRef4))
call xml_AddCharacters(xf, torsion, fmt)
call xml_EndElement(xf, "torsion")
#endif
Expand All @@ -104,8 +104,8 @@ subroutine cmlAddLength_dp(xf, id, atomRef1, atomRef2, length, fmt)

#ifndef DUMMYLIB
call xml_NewElement(xf, "length")
call xml_AddAttribute(xf, "id", id)
call xml_AddAttribute(xf, "atomRefs2", atomRef1//" "//atomRef2)
call xml_AddAttribute(xf, "id", trim(id))
call xml_AddAttribute(xf, "atomRefs2", trim(atomRef1)//" "//trim(atomRef2))
call xml_AddCharacters(xf, length, fmt)
call xml_EndElement(xf, "length")
#endif
Expand All @@ -123,8 +123,8 @@ subroutine cmlAddAngle_dp(xf, id, atomRef1, atomRef2, atomRef3, angle, fmt)

#ifndef DUMMYLIB
call xml_NewElement(xf, "angle")
call xml_AddAttribute(xf, "id", id)
call xml_AddAttribute(xf, "atomRefs3", atomRef1//" "//atomRef2//" "//atomRef3)
call xml_AddAttribute(xf, "id", trim(id))
call xml_AddAttribute(xf, "atomRefs3", trim(atomRef1)//" "//trim(atomRef2)//" "//trim(atomRef3))
call xml_AddCharacters(xf, angle, fmt)
call xml_EndElement(xf, "angle")
#endif
Expand All @@ -143,9 +143,9 @@ subroutine cmlAddTorsion_dp(xf, id, atomRef1, atomRef2, atomRef3, atomRef4, tors

#ifndef DUMMYLIB
call xml_NewElement(xf, "torsion")
call xml_AddAttribute(xf, "id", id)
call xml_AddAttribute(xf, "id", trim(id))
call xml_AddAttribute(xf, "atomRefs4", &
atomRef1//" "//atomRef2//" "//atomRef3//" "//atomRef4)
trim(atomRef1)//" "//trim(atomRef2)//" "//trim(atomRef3)//" "//trim(atomRef4))
call xml_AddCharacters(xf, torsion, fmt)
call xml_EndElement(xf, "torsion")
#endif
Expand Down
12 changes: 6 additions & 6 deletions wcml/m_wcml_geometry.m4
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ define(`TOHWM4_geometry_subs', `dnl

#ifndef DUMMYLIB
call xml_NewElement(xf, "length")
call xml_AddAttribute(xf, "id", id)
call xml_AddAttribute(xf, "atomRefs2", atomRef1//" "//atomRef2)
call xml_AddAttribute(xf, "id", trim(id))
call xml_AddAttribute(xf, "atomRefs2", trim(atomRef1)//" "//trim(atomRef2))
call xml_AddCharacters(xf, length, fmt)
call xml_EndElement(xf, "length")
#endif
Expand All @@ -28,8 +28,8 @@ define(`TOHWM4_geometry_subs', `dnl

#ifndef DUMMYLIB
call xml_NewElement(xf, "angle")
call xml_AddAttribute(xf, "id", id)
call xml_AddAttribute(xf, "atomRefs3", atomRef1//" "//atomRef2//" "//atomRef3)
call xml_AddAttribute(xf, "id", trim(id))
call xml_AddAttribute(xf, "atomRefs3", trim(atomRef1)//" "//trim(atomRef2)//" "//trim(atomRef3))
call xml_AddCharacters(xf, angle, fmt)
call xml_EndElement(xf, "angle")
#endif
Expand All @@ -48,9 +48,9 @@ define(`TOHWM4_geometry_subs', `dnl

#ifndef DUMMYLIB
call xml_NewElement(xf, "torsion")
call xml_AddAttribute(xf, "id", id)
call xml_AddAttribute(xf, "id", trim(id))
call xml_AddAttribute(xf, "atomRefs4", &
atomRef1//" "//atomRef2//" "//atomRef3//" "//atomRef4)
trim(atomRef1)//" "//trim(atomRef2)//" "//trim(atomRef3)//" "//trim(atomRef4))
call xml_AddCharacters(xf, torsion, fmt)
call xml_EndElement(xf, "torsion")
#endif
Expand Down
8 changes: 4 additions & 4 deletions wcml/m_wcml_lattice.F90
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ subroutine cmlAddCrystalsp(xf, a, b, c, alpha, beta, gamma, z,&

#ifndef DUMMYLIB
call xml_NewElement(xf=xf, name="crystal")
if (present(id)) call xml_AddAttribute(xf, "id", id)
if (present(id)) call xml_AddAttribute(xf, "id", trim(id))
if (present(title)) call xml_AddAttribute(xf, "title", title)
if (present(dictref)) call xml_AddAttribute(xf, "dictRef", dictRef)
if (present(convention)) call xml_AddAttribute(xf, "convention", convention)
Expand Down Expand Up @@ -115,7 +115,7 @@ subroutine cmlAddLatticesp(xf, cell, units, title, id, dictref, convention, latt
integer :: i

call xml_NewElement(xf, "lattice")
if (present(id)) call xml_AddAttribute(xf, "id", id)
if (present(id)) call xml_AddAttribute(xf, "id", trim(id))
if (present(title)) call xml_AddAttribute(xf, "title", title)
if (present(dictref)) call xml_AddAttribute(xf, "dictRef", dictref)
if (present(convention)) call xml_AddAttribute(xf, "convention", convention)
Expand Down Expand Up @@ -160,7 +160,7 @@ subroutine cmlAddCrystaldp(xf, a, b, c, alpha, beta, gamma, z,&

#ifndef DUMMYLIB
call xml_NewElement(xf=xf, name="crystal")
if (present(id)) call xml_AddAttribute(xf, "id", id)
if (present(id)) call xml_AddAttribute(xf, "id", trim(id))
if (present(title)) call xml_AddAttribute(xf, "title", title)
if (present(dictref)) call xml_AddAttribute(xf, "dictRef", dictRef)
if (present(convention)) call xml_AddAttribute(xf, "convention", convention)
Expand Down Expand Up @@ -214,7 +214,7 @@ subroutine cmlAddLatticedp(xf, cell, units, title, id, dictref, convention, latt
integer :: i

call xml_NewElement(xf, "lattice")
if (present(id)) call xml_AddAttribute(xf, "id", id)
if (present(id)) call xml_AddAttribute(xf, "id", trim(id))
if (present(title)) call xml_AddAttribute(xf, "title", title)
if (present(dictref)) call xml_AddAttribute(xf, "dictRef", dictref)
if (present(convention)) call xml_AddAttribute(xf, "convention", convention)
Expand Down
4 changes: 2 additions & 2 deletions wcml/m_wcml_lattice.m4
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ define(`TOHWM4_lattice_subs', `dnl

#ifndef DUMMYLIB
call xml_NewElement(xf=xf, name="crystal")
if (present(id)) call xml_AddAttribute(xf, "id", id)
if (present(id)) call xml_AddAttribute(xf, "id", trim(id))
if (present(title)) call xml_AddAttribute(xf, "title", title)
if (present(dictref)) call xml_AddAttribute(xf, "dictRef", dictRef)
if (present(convention)) call xml_AddAttribute(xf, "convention", convention)
Expand Down Expand Up @@ -73,7 +73,7 @@ define(`TOHWM4_lattice_subs', `dnl
integer :: i

call xml_NewElement(xf, "lattice")
if (present(id)) call xml_AddAttribute(xf, "id", id)
if (present(id)) call xml_AddAttribute(xf, "id", trim(id))
if (present(title)) call xml_AddAttribute(xf, "title", title)
if (present(dictref)) call xml_AddAttribute(xf, "dictRef", dictref)
if (present(convention)) call xml_AddAttribute(xf, "convention", convention)
Expand Down
2 changes: 1 addition & 1 deletion wcml/m_wcml_metadata.F90
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ subroutine cmlAddMetadata(xf, name, content, convention, dictRef, id, title )
call xml_AddAttribute(xf, "name", name)
call xml_AddAttribute(xf, name="content", value=content )
if (present(dictref)) call xml_AddAttribute(xf, "dictRef", dictref)
if (present(id)) call xml_AddAttribute(xf, "id", title)
if (present(id)) call xml_AddAttribute(xf, "id", trim(id))
if (present(title)) call xml_AddAttribute(xf, "title", title)
if (present(convention)) call xml_AddAttribute(xf, "convention", convention)
call xml_EndElement(xf, "metadata")
Expand Down
Loading

0 comments on commit 282b2bc

Please sign in to comment.