
org.enhydra.xml.lazydom.html.edit-html-dom.sh Maven / Gradle / Ivy
The newest version!
#!/bin/sh
#
# Edit one of the Xerces HTML DOM Java source files to derive from the lazy
# DOM.
#
# edit-html-dom in.java out.java
#
# This makes the following edits:
# - Change package name.
# - Change package for some imports.
# - Change several references from ElementImpl to LazyElement,
# - Change HTMLElementImpl to LazyHTMLElement
# - Change the element constructors to accept a template argument
# and pass it to super.
# - Change several explict news of elements to pass in a null template.
# - Changed one cast to ElementImpl into a cast to Element, which was
# all that was really needed.
# - Change references to HTMLDocumentImpl to LazyHTMLDocument
# - Add import of LazyElement;
# - Modify getChildNodes() of HTMLFormElementImpl and HTMLSelectElementImpl
# to expand children. These are the only two special cases where this
# is needed since all other elements inherit getChildNodes() from
# LazyElementNoNS which already does this.
#
if [ $# != 2 ] ; then
echo "wrong # arguments: edit-html-dom in.java out.java" >&2
exit 1
fi
inFile="$1"
outFile="$2"
rm -f $outFile
sed -e 's/org\.enhydra\.apache\.html\.dom/org.enhydra.xml.lazydom.html/' \
-e 's/org\.enhydra\.apache\.xerces\.dom\.ElementImpl/org.enhydra.xml.lazydom.LazyElement/' \
-e 's/ ElementImpl/ LazyElementNoNS/' \
-e 's/extends HTMLElementImpl/extends LazyHTMLElement/' \
-e 's/HTMLDocumentImpl owner, String name/LazyHTMLDocument owner, LazyElement template, String name/' \
-e 's/super( owner, name/super( owner, template, name/' \
-e 's/(HTMLDocumentImpl) getOwnerDocument(),/(LazyHTMLDocument) getOwnerDocument(), null,/' \
-e 's/(ElementImpl)/(Element)/' \
-e 's/HTMLDocumentImpl/LazyHTMLDocument/' \
-e '/^package/a\
import org.enhydra.xml.lazydom.LazyElement;\
import org.enhydra.xml.lazydom.LazyElementNoNS;\
' \
-e '/public NodeList getChildNodes\(\)/a\
if \(\!areChildrenExpanded\(\)\) \{\
expandChildren\(\);\
}\
' \
$inFile > $outFile
© 2015 - 2025 Weber Informatics LLC | Privacy Policy