⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 extensionclient.java

📁 目前在JAVA下编程时对XML的操作很重要
💻 JAVA
字号:
import org.apache.xmlbeans.*;
import com.localInfo.*;
import com.weather.*;
import java.io.File;

// Illustrates XMLBeans client application calling extended methods added to XMLBeans using Extension feature.

public class extensionClient {

	public static void main(String args[]) {

		try {

				if (args.length < 1 ) {

					System.out.println("Usage : java extensionClient <<InputFilePath>>");
					return;

				}

				String filePath = args[0];
				java.io.File inputXMLFile = new java.io.File(filePath);

	// Use XMLBeans built in class XmlObject to parse an XML document.

				XmlObject xmlObjExpected = XmlObject.Factory.parse(inputXMLFile);


	// Check document type of the object returned by the call to XmlObject.Factory.parse() method.
	// If type of object returned is of com.localInfo.LocalInfoDocumentXmlBean, then input xml document conforms to
	// localInfo.xsd .

				if (xmlObjExpected instanceof com.localInfo.LocalInfoDocumentXmlBean) {

					com.localInfo.LocalInfoDocumentXmlBean localInfoDoc = (com.localInfo.LocalInfoDocumentXmlBean)xmlObjExpected;
					LocalInfoDocumentXmlBean.LocalInfo localInfoObject = localInfoDoc.getLocalInfo();
					LocalWeatherDocumentXmlBean.LocalWeather localWeatherObject = localInfoObject.getLocalWeather();

	// Get temparature data in Celcius.

					float tempratureCelcius = localWeatherObject.getTemperatureInCelsius();

	// Get temparature data in Fahrenheit.

					float tempratureFahrenheit = localWeatherObject.getTemperature();

					System.out.println
					("Temprature of a location at zipcode " + localWeatherObject.getZipcode()  + " is: \n");

					System.out.print
					(tempratureFahrenheit  + " Fahrenheit or ");

					System.out.println
					(tempratureCelcius  + " Celcius. \n");


				} else {
					System.out.println("Input xml document doesn't" +
					"conform to localInfo.xsd");
				}


			} catch (Exception e) {


				e.printStackTrace();
			}

	}

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -