List of usage examples for org.dom4j QName QName
public QName(String name, Namespace namespace)
From source file:seostudio.Sitemap.java
License:Apache License
public static String generateSitemap(Collection<Result> results) throws IOException { Namespace namespace = new Namespace("", "http://www.sitemaps.org/schemas/sitemap/0.9"); Namespace xsi = new Namespace("xsi", "http://www.w3.org/2001/XMLSchema-instance"); Element urlset = DocumentHelper.createElement(new QName("urlset", namespace)); urlset.addAttribute(new QName("schemaLocation", xsi), "http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd"); Document document = DocumentHelper.createDocument(urlset); for (Result result : results) { if (!result.visited || !result.index) continue; Element url = DocumentHelper.createElement(new QName("url", namespace)); Element loc = DocumentHelper.createElement(new QName("loc", namespace)); Element priority = DocumentHelper.createElement(new QName("priority", namespace)); loc.setText(result.url);/* ww w .ja v a2 s .com*/ if (result.depth == 0) { priority.setText("1.0"); } else { priority.setText("0.8"); } url.add(loc); url.add(priority); urlset.add(url); } StringWriter out = new StringWriter(); new XMLWriter(out, OutputFormat.createCompactFormat()).write(document); return out.toString(); }
From source file:simpel.FileHelper.java
License:GNU General Public License
public static String buildPLFileContents(Process proc, Map<String, ServiceDetails> plMap, Map<String, ImportDetails> nsMap) { if (proc.getImports().size() == 0) return null; Namespace plnk, wsdl;//from w w w .j a va 2 s . c om Document doc = DocumentHelper.createDocument(); Element root = doc.addElement("definitions").addAttribute("targetNamespace", "http://tempuri.org/plks") .addNamespace("tns", "http://tempuri.org/plks") .addNamespace("plnk", "http://docs.oasis-open.org/wsbpel/2.0/plnktype") .addNamespace("pns", "http://www.uatx.mx/uri").addNamespace("", "http://schemas.xmlsoap.org/wsdl/") .addNamespace("wsdl", "http://schemas.xmlsoap.org/wsdl/"); wsdl = root.getNamespaceForPrefix("wsdl"); plnk = root.getNamespaceForPrefix("plnk"); LinkedList<Element> imports = new LinkedList<Element>(); LinkedList<Element> plnks = new LinkedList<Element>(); for (ServiceDetails sd : plMap.values()) { String prefix = sd.porttype.getQName().getPrefix(); String localpart = sd.porttype.getQName().getLocalPart(); String uri = sd.porttype.getQName().getNamespaceURI(); String location = nsMap.get(prefix).location; root.addNamespace(prefix, uri); Element imp = DocumentHelper.createElement(new QName("import", wsdl)).addAttribute("namespace", uri) .addAttribute("location", location); imports.add(imp); Element plnkt = DocumentHelper.createElement(new QName("partnerLinkType", plnk)).addAttribute("name", sd.partnerlink.getName() + "Type"); Element role = plnkt.addElement(new QName("role", plnk)); if (sd.partnerlink.getMyRole() != null) role.addAttribute("name", sd.partnerlink.getMyRole().getName()); else role.addAttribute("name", sd.partnerlink.getPartnerRole().getName()); role.addAttribute("portType", prefix + ":" + localpart); plnks.add(plnkt); } for (Element imp : imports) root.add(imp); for (Element plnkt : plnks) root.add(plnkt); StringWriter out = new StringWriter(); OutputFormat format = OutputFormat.createPrettyPrint(); XMLWriter writer = new XMLWriter(out, format); try { writer.write(doc); } catch (IOException e) { e.printStackTrace(); } return out.toString(); }
From source file:simpel.FileHelper.java
License:GNU General Public License
public static String buildDeployFileContents(Process proc, Map<String, ServiceDetails> plMap, Map<String, ImportDetails> nsMap) { if (proc.getImports().size() == 0) return null; Document doc = DocumentHelper.createDocument(); Namespace ns = DocumentHelper.createNamespace("", "http://www.apache.org/ode/schemas/dd/2007/03"); Element root = doc.addElement(new QName("deploy", ns)).addNamespace("pns", proc.getTargetNamespace()); Element pelement = root.addElement(new QName("process", ns)).addAttribute("name", "pns:" + proc.getName()); pelement.addElement(new QName("active", ns)).addText("true"); LinkedList<Element> invokes = new LinkedList<Element>(); for (ServiceDetails sd : plMap.values()) { String prefix = sd.porttype.getQName().getPrefix(); String uri = sd.porttype.getQName().getNamespaceURI(); Element elem;/*from w ww . j a va 2 s .co m*/ if (sd.partnerlink.getMyRole() != null) elem = pelement.addElement(new QName("provide", ns)); else { elem = DocumentHelper.createElement(new QName("invoke", ns)); invokes.add(elem); } elem.addAttribute("partnerLink", sd.partnerlink.getName()).addElement("service") .addNamespace(prefix, uri).addAttribute("name", sd.service).addAttribute("port", sd.port); } for (Element inv : invokes) pelement.add(inv); StringWriter out = new StringWriter(); OutputFormat format = OutputFormat.createPrettyPrint(); XMLWriter writer = new XMLWriter(out, format); try { writer.write(doc); } catch (IOException e) { e.printStackTrace(); } return out.toString(); }
From source file:to.networld.android.divedroid.model.rdf.RDFParser.java
License:Open Source License
@SuppressWarnings("unchecked") protected String getResourceLinkNodes(String _query, String _resource) { try {/*from w w w. ja va2 s .c o m*/ XPath xpath = new Dom4jXPath(_query); xpath.setNamespaceContext(new SimpleNamespaceContext(this.namespace)); List<Element> elements = (List<Element>) xpath.selectNodes(this.document); if (elements.size() > 0) return elements.get(0).attributeValue( new QName("resource", new Namespace("rdf", "http://www.w3.org/1999/02/22-rdf-syntax-ns#"))); } catch (JaxenException e) { e.printStackTrace(); } return null; }
From source file:to.networld.fbtosemweb.FacebookToFOAF.java
License:Open Source License
private void addFoafEntry(Element _rootNode, String _foafName, String _fbValue) throws JSONException { String name = (String) this.agent.getProperty(_fbValue); if (name != null) _rootNode.addElement(new QName(_foafName, FOAF_NS)).setText(name); }
From source file:to.networld.fbtosemweb.FacebookToFOAF.java
License:Open Source License
private void addHoldsAccount(Element _rootNode, String _serviceHomepage, String _profilePage, String _profileName) {//w ww .ja va 2 s .c om Element holdsAccount = _rootNode.addElement(new QName("holdsAccount", FOAF_NS)); Element onlineAccount = holdsAccount.addElement(new QName("OnlineAccount", FOAF_NS)); onlineAccount.addElement(new QName("accountServiceHomepage", FOAF_NS)) .addAttribute(new QName("resource", RDF_NS), _serviceHomepage); onlineAccount.addElement(new QName("accountProfilePage", FOAF_NS)) .addAttribute(new QName("resource", RDF_NS), _profilePage); onlineAccount.addElement(new QName("accountName", FOAF_NS)).setText(_profileName); }
From source file:to.networld.fbtosemweb.FacebookToFOAF.java
License:Open Source License
private void createFOAF() throws IOException, JSONException { this.agent = this.agentHandler.getFacebookAgent(); Element rootNode = this.rdfDocument.addElement(new QName("RDF", RDF_NS)); rootNode.add(FOAF_NS);//from w ww. j av a 2 s . c o m rootNode.add(DC_NS); rootNode.add(DCT_NS); rootNode.add(RDFS_NS); /** * Start foaf:PersonalProfileDocument */ Element personalProfileDocumentNode = rootNode.addElement(new QName("PersonalProfileDocument", FOAF_NS)); personalProfileDocumentNode.addAttribute(new QName("about", RDF_NS), ""); personalProfileDocumentNode.addElement(new QName("title", DC_NS)) .setText("FOAF File of Facebook User " + this.agent.getID()); // personalProfileDocumentNode.addElement(new QName("created", DCT_NS)).setText(DateHelper.getXSDDateTime()); personalProfileDocumentNode.addElement(new QName("modified", DCT_NS)) .setText((String) this.agent.getProperty("updated_time")); personalProfileDocumentNode.addElement(new QName("maker", FOAF_NS)) .addAttribute(new QName("resource", RDF_NS), "http://fbtofoaf.networld.to/"); personalProfileDocumentNode.addElement(new QName("primaryTopic", FOAF_NS)) .addAttribute(new QName("resource", RDF_NS), "#me"); /** * Start foaf:Person Block */ Element foafNode = rootNode.addElement(new QName("Person", FOAF_NS)); foafNode.addAttribute(new QName("about", RDF_NS), "#me"); this.addFoafEntry(foafNode, "name", "name"); this.addFoafEntry(foafNode, "nick", "username"); this.addFoafEntry(foafNode, "gender", "gender"); this.addFoafEntry(foafNode, "firstName", "first_name"); this.addFoafEntry(foafNode, "lastName", "last_name"); foafNode.addElement(new QName("thumbnail", FOAF_NS)).addAttribute(new QName("resource", RDF_NS), "https://graph.facebook.com/" + this.agent.getID() + "/picture"); try { String locationName = this.agent.getLocationName(); String locationID = this.agent.getLocationID(); Element basedNear = foafNode.addElement(new QName("based_near", FOAF_NS)); Element geoPoint = basedNear.addElement(new QName("Point", GEO_NS)); geoPoint.addElement(new QName("title", DC_NS)).setText(locationName); geoPoint.addElement(new QName("seeAlso", RDFS_NS)).addAttribute(new QName("resource", RDF_NS), "https://graph.facebook.com/" + locationID); } catch (JSONException e) { // TODO: Log here something, at least during development. } Vector<FacebookEducationEntity> eduVector = this.agent.getEducation(); for (FacebookEducationEntity entry : eduVector) { Element schoolHomepage = foafNode.addElement(new QName("schoolHomepage", FOAF_NS)); schoolHomepage.addAttribute(new QName("label", RDFS_NS), entry.getSchoolName()); schoolHomepage.addAttribute(new QName("resource", RDF_NS), "https://graph.facebook.com/" + entry.getSchoolID()); } Vector<FacebookEmployerEntity> employerVector = this.agent.getWork(); for (FacebookEmployerEntity entry : employerVector) { try { Element workplaceHomepage = foafNode.addElement(new QName("workplaceHomepage", FOAF_NS)); workplaceHomepage.addAttribute(new QName("label", RDFS_NS), entry.getEmployerName()); workplaceHomepage.addAttribute(new QName("resource", RDF_NS), "https://graph.facebook.com/" + entry.getEmployerID()); } catch (JSONException e) { // TODO: Log here something, at least during development. } } String profileName = (String) this.agent.getProperty("username"); if (profileName == null) profileName = this.agent.getID(); String profilePage = (String) this.agent.getProperty("link"); this.addHoldsAccount(foafNode, "http://www.facebook.com", profilePage, profileName); Vector<FacebookLikesEntry> likes = this.agentHandler.getLikesConcepts(); for (FacebookLikesEntry entry : likes) { // XXX: Maybe better FOAF Concept for Likes Pages is topic_interest Element interest = foafNode.addElement(new QName("interests", FOAF_NS)); interest.addAttribute(new QName("resource", RDF_NS), "http://graph.facebook.com/" + entry.getID()); interest.addAttribute(new QName("label", RDFS_NS), entry.getName()); } Vector<FacebookFriendEntry> friends = this.agentHandler.getFriends(); for (FacebookFriendEntry entry : friends) { String friendURL = "http://graph.facebook.com/" + entry.getID(); foafNode.addElement(new QName("knows", FOAF_NS)).addAttribute(new QName("resource", RDF_NS), friendURL); Element friendNode = rootNode.addElement(new QName("Person", FOAF_NS)); friendNode.addElement(new QName("name", FOAF_NS)).setText(entry.getName()); friendNode.addElement(new QName("thumbnail", FOAF_NS)).addAttribute(new QName("resource", RDF_NS), friendURL + "/picture"); } }
From source file:to.networld.fbtosemweb.FacebookToSIOC.java
License:Open Source License
/** * TODO: If a link was posted, add also the link to the SIOC block. * @throws IOException/*from ww w . ja v a 2 s.c o m*/ * @throws JSONException */ public void createSIOC() throws IOException, JSONException { Element rootNode = this.rdfDocument.addElement(new QName("RDF", RDF_NS)); rootNode.add(SIOC_NS); rootNode.add(DCT_NS); JSONArray wallEntries = this.object.getJSONArray("data"); for (int count = 0; count < wallEntries.length(); count++) { JSONObject wallEntry = (JSONObject) wallEntries.get(count); Element siocPost = rootNode.addElement(new QName("Post", SIOC_NS)).addAttribute( new QName("about", RDF_NS), "http://graph.facebook.com/" + wallEntry.getString("id")); siocPost.addElement(new QName("content", SIOC_NS)).setText(wallEntry.getString("message")); String creatorID = wallEntry.getJSONObject("from").getString("id"); siocPost.addElement(new QName("hasCreator", SIOC_NS)).addAttribute(new QName("resource", RDF_NS), "http://graph.facebook.com/" + creatorID); try { siocPost.addElement(new QName("created", SIOC_NS)).setText(wallEntry.getString("created_time")); } catch (JSONException e) { } try { siocPost.addElement(new QName("modified", SIOC_NS)).setText(wallEntry.getString("updated_time")); } catch (JSONException e) { } try { JSONArray comments = wallEntry.getJSONObject("comments").getJSONArray("data"); for (int count1 = 0; count1 < comments.length(); count1++) { JSONObject comment = comments.getJSONObject(count1); Element replyNode = siocPost.addElement(new QName("has_reply", SIOC_NS)); Element replyPost = replyNode.addElement(new QName("Post", SIOC_NS)); replyPost.addAttribute(new QName("about", RDF_NS), "http://graph.facebook.com/" + comment.getString("id")); replyPost.addElement(new QName("content", SIOC_NS)).setText(comment.getString("message")); String replierID = comment.getJSONObject("from").getString("id"); replyPost.addElement(new QName("hasCreator", SIOC_NS)) .addAttribute(new QName("resource", RDF_NS), "http://graph.facebook.com/" + replierID); try { replyPost.addElement(new QName("created", SIOC_NS)) .setText(comment.getString("created_time")); } catch (JSONException e) { } try { replyPost.addElement(new QName("modified", SIOC_NS)) .setText(comment.getString("updated_time")); } catch (JSONException e) { } } } catch (JSONException e) { // TODO: Log here something, at least during development. } } }
From source file:to.networld.security.common.data.ArtifactResolve.java
License:Open Source License
private void writeMessage(String _id, String _issuer, String _artifactID, String _destination, String _version, String _issueInstant) {//from w w w .j a va 2s.com Element artifactResolveNode = this.xmlDocument.addElement(new QName("ArtifactResolve", SAMLP_NS)); artifactResolveNode.add(SAML_NS); artifactResolveNode.addAttribute("ID", _id); artifactResolveNode.addAttribute("Version", _version); artifactResolveNode.addAttribute("IssueInstant", _issueInstant); artifactResolveNode.addAttribute("Destination", _destination); Element issuerNode = artifactResolveNode.addElement(new QName("Issuer", SAML_NS)); issuerNode.addText(_issuer); Element artifactNode = artifactResolveNode.addElement(new QName("Artifact", SAMLP_NS)); artifactNode.setText(_artifactID); }
From source file:to.networld.security.common.data.AuthnRequest.java
License:Open Source License
private void writeAuthnRequest(String _id, String _issueInstant, String _issuer, String _nameIDFormat, String _version, String _allowCreate, String _assertionConsumerServiceIndex, String _attributeConsumingServiceIndex) { Element authnRequestNode = this.xmlDocument.addElement(new QName("AuthnRequest", SAMLP_NS)); authnRequestNode.add(SAML_NS);// w ww .j a v a 2s . c om authnRequestNode.addAttribute("ID", _id); authnRequestNode.addAttribute("Version", _version); authnRequestNode.addAttribute("IssueInstant", _issueInstant); authnRequestNode.addAttribute("AssertionConsumerServiceIndex", _assertionConsumerServiceIndex); authnRequestNode.addAttribute("AttributeConsumingServiceIndex", _attributeConsumingServiceIndex); Element issuerNode = authnRequestNode.addElement(new QName("Issuer", SAML_NS)); issuerNode.setText(_issuer); Element namedIDPolicyNode = authnRequestNode.addElement(new QName("NameIDPolicy", SAMLP_NS)); namedIDPolicyNode.addAttribute("AllowCreate", _allowCreate); namedIDPolicyNode.addAttribute("Format", _nameIDFormat); }