You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by sa...@apache.org on 2003/08/18 21:21:44 UTC
cvs commit: xml-xerces/java/samples/xni PSVIWriter.java
sandygao 2003/08/18 12:21:44
Modified: java/samples/xni PSVIWriter.java
Log:
Committing the patch from Peter McCracken to avoid potential NPE's.
Revision Changes Path
1.21 +42 -13 xml-xerces/java/samples/xni/PSVIWriter.java
Index: PSVIWriter.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/samples/xni/PSVIWriter.java,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -r1.20 -r1.21
--- PSVIWriter.java 30 Jul 2003 19:22:22 -0000 1.20
+++ PSVIWriter.java 18 Aug 2003 19:21:44 -0000 1.21
@@ -416,13 +416,14 @@
"",
"http://www.w3.org/2001/05/XMLInfoset");
- if (fDocumentHandler != null) {
- fDocumentHandler.startDocument(
- locator,
- "UTF-8",
- fPSVINamespaceContext,
- null);
- }
+ if (fDocumentHandler == null)
+ return;
+
+ fDocumentHandler.startDocument(
+ locator,
+ "UTF-8",
+ fPSVINamespaceContext,
+ null);
Vector attributes = new Vector();
attributes.add("xmlns:xsi");
@@ -456,6 +457,9 @@
String standalone,
Augmentations augs)
throws XNIException {
+ if (fDocumentHandler == null)
+ return;
+
sendElementEvent("characterEncodingScheme", encoding);
sendElementEvent("standalone", standalone);
sendElementEvent("version", version);
@@ -479,6 +483,9 @@
String systemId,
Augmentations augs)
throws XNIException {
+ if (fDocumentHandler == null)
+ return;
+
checkForChildren();
sendIndentedElement("docTypeDeclaration");
if (publicId != null)
@@ -498,6 +505,9 @@
*/
public void comment(XMLString text, Augmentations augs)
throws XNIException {
+ if (fDocumentHandler == null)
+ return;
+
checkForChildren();
sendIndentedElement("comment");
sendElementEvent("content", text);
@@ -526,6 +536,9 @@
XMLString data,
Augmentations augs)
throws XNIException {
+ if (fDocumentHandler == null)
+ return;
+
checkForChildren();
sendIndentedElement("processingInstruction");
sendElementEvent("target", target);
@@ -553,8 +566,9 @@
XMLAttributes attributes,
Augmentations augs)
throws XNIException {
- if (attributes == null)
- System.err.println("null attributes!");
+ if (fDocumentHandler == null)
+ return;
+
checkForChildren();
_elementState.push(new ElementState(true));
@@ -585,6 +599,9 @@
XMLAttributes attributes,
Augmentations augs)
throws XNIException {
+ if (fDocumentHandler == null)
+ return;
+
sendIndentedElement("element");
sendElementEvent("namespaceName", element.uri);
sendElementEvent("localName", element.localpart);
@@ -612,6 +629,9 @@
*/
public void characters(XMLString text, Augmentations augs)
throws XNIException {
+ if (fDocumentHandler == null)
+ return;
+
checkForChildren();
sendIndentedElement("character");
sendElementEvent("textContent", text);
@@ -635,6 +655,9 @@
*/
public void ignorableWhitespace(XMLString text, Augmentations augs)
throws XNIException {
+ if (fDocumentHandler == null)
+ return;
+
if (fIncludeIgnorableWhitespace) {
this.characters(text, augs);
}
@@ -650,6 +673,9 @@
*/
public void endElement(QName element, Augmentations augs)
throws XNIException {
+ if (fDocumentHandler == null)
+ return;
+
ElementState fElementState = (ElementState)_elementState.peek();
if (fElementState.isEmpty) {
sendEmptyElementEvent("children");
@@ -693,6 +719,9 @@
* @throws XNIException Thrown by handler to signal an error.
*/
public void endDocument(Augmentations augs) throws XNIException {
+ if (fDocumentHandler == null)
+ return;
+
sendUnIndentedElement("children");
sendElementEvent("documentElement");
// these aren't relevent for PSVI
@@ -1752,7 +1781,7 @@
return;
processPSVIElementRef("psv:elementDeclaration", elem);
}
-
+
private void processPSVIElementDeclarationOrRef(XSElementDeclaration elem) {
if (elem == null)
return;
@@ -1760,13 +1789,13 @@
// we always want to print references
if (elem.getScope() == XSConstants.SCOPE_GLOBAL
|| fDefined.contains(this.getID(elem))) {
- processPSVIElementDeclarationRef(elem);
+ processPSVIElementDeclarationRef(elem);
}
else {
processPSVIElementDeclaration(elem);
}
}
-
+
/**
* This method writes an empty element at the current indent level.
*
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-cvs-help@xml.apache.org