本文整理汇总了Java中org.jdom.Namespace.getNamespace方法的典型用法代码示例。如果您正苦于以下问题:Java Namespace.getNamespace方法的具体用法?Java Namespace.getNamespace怎么用?Java Namespace.getNamespace使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jdom.Namespace
的用法示例。
在下文中一共展示了Namespace.getNamespace方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: write
import org.jdom.Namespace; //导入方法依赖的package包/类
public static void write( Writer w, Model newModel, boolean namespaceDeclaration )
throws IOException
{
Element root = new Element( "project" );
if ( namespaceDeclaration )
{
String modelVersion = newModel.getModelVersion();
Namespace pomNamespace = Namespace.getNamespace( "", "http://maven.apache.org/POM/" + modelVersion );
root.setNamespace( pomNamespace );
Namespace xsiNamespace = Namespace.getNamespace( "xsi", "http://www.w3.org/2001/XMLSchema-instance" );
root.addNamespaceDeclaration( xsiNamespace );
if ( root.getAttribute( "schemaLocation", xsiNamespace ) == null )
{
root.setAttribute( "schemaLocation",
"http://maven.apache.org/POM/" + modelVersion + " http://maven.apache.org/maven-v"
+ modelVersion.replace( '.', '_' ) + ".xsd", xsiNamespace );
}
}
Document doc = new Document( root );
MavenJDOMWriter writer = new MavenJDOMWriter();
String encoding = newModel.getModelEncoding() != null ? newModel.getModelEncoding() : "UTF-8";
Format format = Format.getPrettyFormat().setEncoding( encoding );
writer.write( newModel, doc, w, format );
}
示例2: export
import org.jdom.Namespace; //导入方法依赖的package包/类
/**
* @param t_objdb
* @param string
* @throws IOException
* @throws SQLException
*/
public void export(DBInterface a_objDB, String a_strFileName) throws IOException, SQLException
{
this.m_objDB = a_objDB;
// Erzeugung eines XML-Dokuments
Document t_objDocument = new Document();
// Erzeugung des Root-XML-Elements
Element t_objRoot = new Element("fragments");
Namespace xsiNS = Namespace.getNamespace("xsi","http://www.w3.org/2001/XMLSchema-instance");
t_objRoot.addNamespaceDeclaration(xsiNS);
this.exportAX(t_objRoot);
this.exportOthers(t_objRoot);
// Und jetzt haengen wir noch das Root-Element an das Dokument
t_objDocument.setRootElement(t_objRoot);
// Damit das XML-Dokument schoen formattiert wird holen wir uns ein Format
Format t_objFormat = Format.getPrettyFormat();
t_objFormat.setEncoding("iso-8859-1");
// Erzeugung eines XMLOutputters dem wir gleich unser Format mitgeben
XMLOutputter t_objExportXML = new XMLOutputter(t_objFormat);
// Schreiben der XML-Datei in einen String
FileWriter t_objWriter = new FileWriter(a_strFileName);
t_objExportXML.output(t_objDocument, t_objWriter );
}
示例3: getEventElement
import org.jdom.Namespace; //导入方法依赖的package包/类
/**
* @return A file Element for an event in a sentence.
*/
private Element getEventElement(String filename, String eventID) {
Namespace ns = Namespace.getNamespace(INFO_NS);
Element fileobj = getFileElement(filename);
// Check each sentence entry.
List<Element> sentenceElements = fileobj.getChildren(ENTRY_ELEM, ns);
for( Element obj : sentenceElements ) {
Element ev = obj.getChild(EVENTS_ELEM,ns);
// Check each event in this sentence.
List<Element> localevents = ev.getChildren(TextEvent.NAME_ELEM, ns);
for( Element child : localevents )
if( child.getAttributeValue(TextEvent.ID_ELEM).equalsIgnoreCase(eventID) )
return child;
}
return null;
}
示例4: testJaxen20AttributeNamespaceNodes
import org.jdom.Namespace; //导入方法依赖的package包/类
public void testJaxen20AttributeNamespaceNodes() throws JaxenException
{
Namespace ns1 = Namespace.getNamespace("p1", "www.acme1.org");
Namespace ns2 = Namespace.getNamespace("p2", "www.acme2.org");
Element element = new Element("test", ns1);
Attribute attribute = new Attribute("foo", "bar", ns2);
element.setAttribute(attribute);
Document doc = new Document(element);
XPath xpath = new JDOMXPath( "//namespace::node()" );
List results = xpath.selectNodes( doc );
assertEquals( 3,
results.size() );
}
示例5: addEvents
import org.jdom.Namespace; //导入方法依赖的package包/类
/**
* Create a new <events> element in a single sentence. Fill it with the given events.
*/
public void addEvents(String docname, int sid, List<TextEvent> events) {
docname = stripFile(docname);
Namespace ns = Namespace.getNamespace(INFO_NS);
Element mainfile = getFileElement(docname);
// Check each sentence entry
List<Element> children = mainfile.getChildren(ENTRY_ELEM,ns);
Element targetSentenceElement = children.get(sid);
// Add the events vector
if( events != null ) {
Element eventsElem = targetSentenceElement.getChild(EVENTS_ELEM,ns);
if( eventsElem == null ) {
eventsElem = new Element(EVENTS_ELEM,ns);
targetSentenceElement.addContent(eventsElem);
}
for( TextEvent te : events )
eventsElem.addContent(te.toElement(ns));
}
}
示例6: addTimexes
import org.jdom.Namespace; //导入方法依赖的package包/类
/**
* Add the given timexes to a single sentence.
* Create a new <timex> element if there is not already one present.
*/
public void addTimexes(String docname, int sid, List<Timex> timexes) {
docname = stripFile(docname);
Namespace ns = Namespace.getNamespace(INFO_NS);
Element mainfile = getFileElement(docname);
// Check each sentence entry
List<Element> children = mainfile.getChildren(ENTRY_ELEM,ns);
Element targetSentenceElement = children.get(sid);
// Add the timex vector
if( timexes != null ) {
Element timexesElem = targetSentenceElement.getChild(TIMEXES_ELEM,ns);
if( timexesElem == null ) {
timexesElem = new Element(TIMEXES_ELEM,ns);
targetSentenceElement.addContent(timexesElem);
}
for( Timex timex : timexes )
timexesElem.addContent(timex.toElement(ns));
}
}
示例7: deleteTlinks
import org.jdom.Namespace; //导入方法依赖的package包/类
/**
* Deletes all the TLinks from the XML file
*/
public void deleteTlinks(String file) {
file = stripFile(file);
Namespace ns = Namespace.getNamespace(INFO_NS);
Element root = jdomDoc.getRootElement();
// Find the file's Element
Element mainfile = getFileElement(file);
// If we found the element
if( mainfile != null ) {
List children = mainfile.getChildren(TLink.TLINK_ELEM,ns);
int numdel = children.size();
for( int i = 0; i < numdel; i++ ) {
mainfile.removeChild(TLink.TLINK_ELEM,ns);
}
}
}
示例8: getTokens
import org.jdom.Namespace; //导入方法依赖的package包/类
/**
* @return A list of lists.
* This is a list of sentences, each sentence is a list of CoreLabels with character information.
*/
public List<List<CoreLabel>> getTokens(String file) {
file = stripFile(file);
Namespace ns = Namespace.getNamespace(INFO_NS);
Element mainfile = getFileElement(file);
if( mainfile == null ) {
System.err.println("Can't find file " + file + " in document.");
return null;
}
List<List<CoreLabel>> tokens = new ArrayList<List<CoreLabel>>();
// Get each sentence entry.
List<Element> children = mainfile.getChildren(ENTRY_ELEM,ns);
for( Element obj : children ) {
// Get the <tokens> element.
Element ev = obj.getChild(TOKENS_ELEM,ns);
String text = ev.getText();
// Map the string to CoreLabel objects.
tokens.add(stringToCoreLabels(text));
}
return tokens;
}
示例9: parseModules
import org.jdom.Namespace; //导入方法依赖的package包/类
public List parseModules(Element root) {
List parsers = getPlugins();
List modules = null;
for (int i=0;i<parsers.size();i++) {
ModuleParser parser = (ModuleParser) parsers.get(i);
String namespaceUri = parser.getNamespaceUri();
Namespace namespace = Namespace.getNamespace(namespaceUri);
if (hasElementsFrom(root, namespace)) {
Module module = parser.parse(root);
if (module != null) {
if (modules == null) {
modules = new ArrayList();
}
modules.add(module);
}
}
}
return modules;
}
示例10: getDocstamp
import org.jdom.Namespace; //导入方法依赖的package包/类
/**
* @param The filename of the document
* @return A Timex object for the document creation time
*/
public List<Timex> getDocstamp(String file) {
List<Timex> stamps = new ArrayList<Timex>();
file = stripFile(file);
Namespace ns = Namespace.getNamespace(INFO_NS);
Element mainfile = getFileElement(file);
// Get the document time stamps (sometimes more than one, stupid Timebank)
List<Element> elements = mainfile.getChildren(Timex.TIMEX_ELEM,ns);
// Element docstamp = mainfile.getChild(Timex.TIMEX_ELEM,ns);
// if( docstamp != null ) return new Timex(docstamp);
for( Element stamp : elements )
stamps.add(new Timex(stamp));
if( stamps.size() == 0 ) System.out.println("WARNING: no docstamp in " + file);
return stamps;
}
示例11: populateElement
import org.jdom.Namespace; //导入方法依赖的package包/类
private static void populateElement(Element element,
TypeDescriptor descriptor) {
element.setAttribute("optional", String
.valueOf(descriptor.isOptional()));
element.setAttribute("unbounded", String.valueOf(descriptor
.isUnbounded()));
if (descriptor instanceof ArrayTypeDescriptor) {
element.setAttribute("wrapped", String
.valueOf(((ArrayTypeDescriptor) descriptor).isWrapped()));
}
element.setAttribute("typename", descriptor.getType());
element.setAttribute("name", descriptor.getName() == null ? ""
: descriptor.getName());
element.setAttribute("qname", descriptor.getQname().toString());
if (descriptor.getDocumentation() != null){
Element annotationElement =
new Element("annotation", Namespace.getNamespace("xsd", "http://www.w3.org/2001/XMLSchema"));
Element documentationElemenet =
new Element("documentation", Namespace.getNamespace("xsd", "http://www.w3.org/2001/XMLSchema"));
documentationElemenet.setText(descriptor.getDocumentation());
annotationElement.addContent(documentationElemenet);
element.addContent(annotationElement);
}
}
开发者ID:apache,项目名称:incubator-taverna-common-activities,代码行数:26,代码来源:XMLSplitterSerialisationHelper.java
示例12: testNamespaceNodesAreInherited
import org.jdom.Namespace; //导入方法依赖的package包/类
public void testNamespaceNodesAreInherited() throws JaxenException
{
Namespace ns0 = Namespace.getNamespace("p0", "www.acme0.org");
Namespace ns1 = Namespace.getNamespace("p1", "www.acme1.org");
Namespace ns2 = Namespace.getNamespace("p2", "www.acme2.org");
Element element = new Element("test", ns1);
Attribute attribute = new Attribute("foo", "bar", ns2);
element.setAttribute(attribute);
Element root = new Element("root", ns0);
root.addContent(element);
Document doc = new Document(root);
XPath xpath = new JDOMXPath( "/*/*/namespace::node()" );
List results = xpath.selectNodes( doc );
assertEquals( 4, results.size() );
}
示例13: readLayer
import org.jdom.Namespace; //导入方法依赖的package包/类
public GeometryImage readLayer() {
GeometryImage layer=null;
try {
layer = new GeometryImage(GeometryImage.POINT);
SAXBuilder builder = new SAXBuilder();
Document doc = builder.build(input);
GeometryFactory gf = new GeometryFactory();
Element root = doc.getRootElement();
if (root != null) {
layer.setProjection("EPSG:4326");
layer.setName(input.getName());
for (Object obj : root.getChildren()) {
if (obj instanceof Element) {
Element feature = (Element) obj;
if (feature.getName().equals("featureMember")) {
Namespace vd=Namespace.getNamespace("vd", "http://cweb.ksat.no/cweb/schema/vessel");
Namespace gml=Namespace.getNamespace("gml", "http://www.opengis.net/gml");
Element vessel = feature.getChild("feature",vd).getChild("vessel",vd);
AttributesGeometry atts = new AttributesGeometry(VDSSchema.schema);
String point[] = vessel.getChild("Point",gml).getChild("pos",gml).getText().split(" ");
double lon = Double.parseDouble(point[0]);
double lat = Double.parseDouble(point[1]);
Geometry geom = gf.createPoint(new Coordinate(lat, lon));
layer.put(geom, atts);
try {
atts.set(VDSSchema.ID, Double.parseDouble(feature.getChild("feature",vd).getChild("name",gml).getValue()));
atts.set(VDSSchema.ESTIMATED_LENGTH, Double.parseDouble(vessel.getChild("length",vd).getValue()));
atts.set(VDSSchema.ESTIMATED_WIDTH, Double.parseDouble(vessel.getChild("beam",vd).getValue()));
atts.set(VDSSchema.ESTIMATED_HEADING, Double.parseDouble(vessel.getChild("heading",vd).getValue()));
} catch (Exception e) {
//e.printStackTrace();
}
}
}
}
}
} catch (Exception ex) {
logger.error(ex.getMessage(),ex);
}
return layer;
}
示例14: setBaseXPath
import org.jdom.Namespace; //导入方法依赖的package包/类
protected void setBaseXPath(String requestName)
throws JDOMException
{
namespace = Namespace.getNamespace("wps", NAMESPACE_URI);
authnUsernameXPath = XPath.newInstance("/wps:"+requestName+"/wps:authnUsername");
authnUsernameXPath.addNamespace(namespace);
authnPasswordXPath = XPath.newInstance("/wps:"+requestName+"/wps:authnPassword");
authnPasswordXPath.addNamespace(namespace);
}
示例15: getDependencies
import org.jdom.Namespace; //导入方法依赖的package包/类
/**
* @return A List of Strings, one string per sentence, representing dependencies.
*/
public List<String> getDependencies(String filename) {
filename = stripFile(filename);
Namespace ns = Namespace.getNamespace(INFO_NS);
Element fileElement = getFileElement(filename);
List children = fileElement.getChildren(ENTRY_ELEM,ns);
List<String> deps = new ArrayList<String>();
for( Object obj : children ) {
Element depsObj = ((Element)obj).getChild(DEPS_ELEM,ns);
deps.add(depsObj.getText().toString());
}
return deps;
}