List of usage examples for javax.xml XMLConstants W3C_XML_SCHEMA_INSTANCE_NS_URI
String W3C_XML_SCHEMA_INSTANCE_NS_URI
To view the source code for javax.xml XMLConstants W3C_XML_SCHEMA_INSTANCE_NS_URI.
Click Source Link
From source file:com.amalto.core.history.accessor.ManyFieldAccessor.java
public String getActualType() { Attr type = getCollectionItemNode().getAttributeNodeNS(XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI, "type"); //$NON-NLS-1$ if (type == null) { return StringUtils.EMPTY; } else {// w ww . j av a2s .co m return type.getValue(); } }
From source file:com.haulmont.cuba.restapi.XMLConverter.java
/** * Create a new document with the given tag as the root element. * * @param rootTag the tag of the root element * @return the document element of a new document *//* w w w .jav a 2 s . c o m*/ public Element newDocument(String rootTag) { DocumentBuilder builder; try { builder = DocumentBuilderFactory.newInstance().newDocumentBuilder(); } catch (ParserConfigurationException e) { throw new RuntimeException(e); } Document doc = builder.newDocument(); Element root = doc.createElement(rootTag); doc.appendChild(root); String[] nvpairs = new String[] { "xmlns:xsi", XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI, // "xsi:noNamespaceSchemaLocation", INSTANCE_XSD, ATTR_VERSION, "1.0", }; for (int i = 0; i < nvpairs.length; i += 2) { root.setAttribute(nvpairs[i], nvpairs[i + 1]); } return root; }
From source file:net.sf.firemox.xml.magic.Oracle2Xml.java
/** * The main serialization method, used to serialize the given Oracle(TM) text * file to as many XML cards it can parse properly. The parsed cards are * stored in the directory identified by the <code>destinationDir</code> * parameter while the final directory to store the validated cards are stored * in the path represented by the <code>recycledDir</code> parameter. * /* w w w .j av a 2 s.c o m*/ * @param oracleFile * the Oracle(TM) formatted text file * @param destinationDir * the directory where built card will be placed * @param recycledDir * the directory where already built card are placed */ @SuppressWarnings("null") public void serialize(File oracleFile, File destinationDir, File recycledDir) { // input/outputs existence verification verifyInputsOutputs(oracleFile, destinationDir, recycledDir); // Start parsing final StringBuilder cardText = new StringBuilder(); int nbCard = 0; MToolKit.tbsName = TBS_NAME; try { final BufferedReader in = new BufferedReader(new FileReader(oracleFile)); PrintWriter out = null; // we parse until we reach the maximum integer value for the number of // cards while (nbCard < MAXI) { String line = in.readLine(); // if this is the end of the file, we stop parsing, quitting the while // loop if (line == null) break; // the card name is first read String cardName = line.trim(); // if this is an empty line, we skip it if (cardName.length() == 0) { continue; } /* * This portion of the method is dedicated to the parsing of one new * card. */ System.out.println("Parsing [" + cardName + "]"); // we get the XML file name for the generated card String fileName = MToolKit.getExactKeyName(cardName) + ".xml"; // we test wether the card already exists in recycledDir if (new File(recycledDir, fileName).exists()) { // is already validated existing parsed card in recycledDir can be // updated ? if (UPDATE_CARD) { // first, we copy the card to update to a file named "temp" File patchFile = MToolKit .getFile(recycledDir.getAbsolutePath() + File.separator + fileName); File tempFile = File.createTempFile(fileName, "temp"); FileUtils.copyFile(patchFile, tempFile); final BufferedReader inExist = new BufferedReader(new FileReader(tempFile)); final PrintWriter outExist = new PrintWriter(new FileOutputStream(patchFile)); String lineExist = null; boolean found = false; while ((lineExist = inExist.readLine()) != null) { if (!found && lineExist.contains("name=\"")) { lineExist = lineExist.substring(0, lineExist.indexOf("name=\"")) + "name=\"" + cardName + lineExist.substring(lineExist.indexOf("\"", lineExist.indexOf("name=\"") + "name=\"".length() + 2)); found = true; } outExist.println(lineExist); } IOUtils.closeQuietly(inExist); IOUtils.closeQuietly(outExist); if (!found) { System.err.println(">> Error patching card '" + cardName + "'"); // } else { // patching card } } skipCard(in); continue; } out = new PrintWriter(new FileOutputStream(new File(destinationDir, fileName))); int[] manaCost = null; // record the card text cardText.setLength(0); cardText.append("<!--\n\t"); List<String> properties = new ArrayList<String>(); String power = null; String toughness = null; isNonBasicLand = false; isLocalEnchantCreature = false; isLocalEnchantLand = false; isLocalEnchantArtifact = false; isEnchantWorld = false; isLocalEnchantCreatureArtifact = false; isLocalEnchantPermanent = false; isLocalEnchantEnchantment = false; isGlobalEnchant = false; isInstant = false; isCreature = false; isArtifact = false; isSorcery = false; isSwamp = false; isIsland = false; isForest = false; isMountain = false; isPlains = false; isScheme = false; boolean isHybrid = false; boolean isTribal = false; boolean isPlaneswalker = false; boolean isEquipment = false; line = in.readLine().trim().toLowerCase(); cardText.append('\t').append(line).append("\n"); isScheme = line.indexOf("scheme") != -1; isPlane = line.indexOf("plane ") != -1; isPhenomenon = line.indexOf("phenomenon") != -1; if (isScheme || isPlane || isPhenomenon) { // schemes/planes/phenomenons not supported (yet) while (true) { line = in.readLine(); if (line == null || line.length() == 0) break; } new File(destinationDir, fileName).delete(); continue; } isArtifact = line.indexOf("artifact") != -1; if (line.startsWith("land") || line.endsWith(" land")) { isNonBasicLand = true; } else { manaCost = extractManaCost(line); isHybrid = line.contains("("); line = in.readLine().replaceAll("\\(.*\\)", "").toLowerCase(); cardText.append('\t').append(line).append("\n"); isLocalEnchantCreature = line.indexOf("enchant creature") != -1; isEnchantWorld = line.indexOf("world enchantment") != -1; isAura = line.indexOf("aura") != -1; isTribal = line.indexOf("tribal") != -1; isPlaneswalker = line.indexOf("planeswalker") != -1; if (line.indexOf("enchantment") != -1 && !isAura && !isEnchantWorld) isGlobalEnchant = true; if (!isGlobalEnchant && !isAura && !isEnchantWorld && !isLocalEnchantCreature) { isInstant = line.indexOf("instant") != -1; isCreature = line.indexOf("creature") != -1; isSorcery = line.indexOf("sorcery") != -1; isSwamp = line.indexOf("swamp") != -1; isIsland = line.indexOf("island") != -1; isForest = line.indexOf("forest") != -1; isMountain = line.indexOf("mountain") != -1; isArtifact = isArtifact || line.indexOf("artifact") != -1; isPlains = line.indexOf("plains") != -1; } } if (line.indexOf("snow") != -1) properties.add("snow"); if (line.indexOf("legendary") != -1) properties.add("legend"); if (line.indexOf("-") != -1) { properties = extractProperties(line.substring(line.indexOf("--") + 2).trim(), properties); } if (isCreature) { line = in.readLine(); cardText.append('\t').append(line).append("\n"); if (line.indexOf("/") == -1) { System.err.println("Error reading card '" + cardName + "' : power/toughness, line=" + line); skipCard(in); continue; } power = line.substring(0, line.indexOf('/')).trim(); toughness = line.substring(line.indexOf('/') + 1).trim(); } if (isEnchantWorld) { properties.add("enchant-world"); } if (properties.contains("equipment")) isEquipment = true; List<String> lineBuffer = new ArrayList<String>(); boolean hasBuyBack = false; boolean hasFlashBack = false; boolean hasForecast = false; boolean hasAffinity = false; boolean hasRampage = false; boolean hasTransmute = false; boolean hasDredge = false; boolean hasHaunt = false; boolean hasBloodThirst = false; boolean hasBushido = false; String hasTransmuteCost = null; int hasRampageCount = 1; int hasDredgeCount = 1; int hasBloodThirstCount = 1; int hasBushidoCount = 1; boolean hasFading = false; boolean hasLessToPlay = false; boolean hasMoreToPlay = false; boolean hasVanishing = false; lowerCard = cardName.toLowerCase(); String hasBuyBackLine = null; String hasFlashBackLine = null; String hasAffinityLine = null; String hasForecastLine = null; String hasFadingLine = null; String hasVanishingLine = null; String hasSuspendLine = null; boolean hasFlanking = false; boolean hasHaunting = false; boolean hasSuspend = false; boolean hasLifelink = false; boolean hasDeathtouch = false; String equipLine = ""; String lastLine = null; while (true) { line = in.readLine(); if (line == null || line.length() == 0) break; // we drop the last line if (lastLine != null && lastLine.length() > 0) { lastLine = updateProperties(lastLine, properties); lineBuffer.add(lastLine); } lastLine = null; //line = line.replaceAll("T ", "T :").replaceAll("\\(.*\\)", "").toLowerCase(); line = line.replaceAll("T ", "T :").toLowerCase(); cardText.append('\t').append(line).append('\n'); if (isAura && !isLocalEnchantCreature && !isLocalEnchantLand && !isLocalEnchantCreatureArtifact && !isLocalEnchantArtifact && !isLocalEnchantPermanent && !isLocalEnchantEnchantment) { isLocalEnchantCreature = line.indexOf("enchant creature") != -1; isLocalEnchantLand = line.indexOf("enchant land") != -1; isLocalEnchantCreatureArtifact = line.indexOf("enchant artifact creature") != -1; isLocalEnchantArtifact = !isLocalEnchantCreatureArtifact && line.indexOf("enchant artifact") != -1; isLocalEnchantPermanent = line.indexOf("enchant permanent") != -1; isLocalEnchantEnchantment = line.indexOf("enchant enchantment") != -1; } if (line.startsWith("buyback")) { hasBuyBack = true; hasBuyBackLine = line.substring("buyback".length()).replaceAll("\\(.*\\)", "").trim(); continue; } else if (line.startsWith("haunt")) { hasHaunt = true; continue; } else if (line.startsWith("flashback")) { hasFlashBack = true; hasFlashBackLine = line.substring("flashback".length()).replaceAll("\\(.*\\)", "").trim(); continue; } else if (line.startsWith("affinity for ")) { hasAffinity = true; hasAffinityLine = line.substring("affinity for ".length()).replaceAll("\\(.*\\)", "") .trim(); continue; } else if (line.startsWith("forecast")) { hasForecast = true; hasForecastLine = line.substring("forecast - ".length()).replaceAll("\\(.*\\)", "").trim(); continue; } else if (line.startsWith("rampage ")) { hasRampage = true; hasRampageCount = Integer .parseInt(line.substring("rampage ".length(), "rampage ".length() + 1).trim()); continue; } else if (line.startsWith("transmute ")) { hasTransmute = true; hasTransmuteCost = line.substring("transmute ".length()).replaceAll("\\(.*\\)", "").trim(); continue; } else if (line.startsWith("dredge ")) { hasDredge = true; hasDredgeCount = Integer .parseInt(line.substring("dredge ".length(), "dredge ".length() + 1).trim()); continue; } else if (line.startsWith("bloodthirst ")) { hasBloodThirst = true; String bloodThirst = line.substring("bloodthirst ".length(), "bloodthirst ".length() + 1) .trim(); if (bloodThirst.compareTo("x") != 0) hasBloodThirstCount = Integer.parseInt(bloodThirst); else hasBloodThirstCount = 0; // 0 must be changed to a variable that // counts damage opponent has taken the present turn continue; } else if (line.startsWith("bushido ")) { hasBushido = true; hasBushidoCount = Integer .parseInt(line.substring("bushido ".length(), "bushido ".length() + 1).trim()); continue; } else if (line.startsWith("fading")) { hasFading = true; hasFadingLine = line.substring("fading".length()).replaceAll("\\(.*\\)", "").trim(); continue; } else if (line.startsWith("vanishing")) { hasVanishing = true; hasVanishingLine = line.substring("vanishing".length()).replaceAll("\\(.*\\)", "").trim(); continue; } else if (line.startsWith("flanking")) { hasFlanking = true; continue; } else if (line.startsWith("haunt")) { hasHaunting = true; continue; } else if (line.startsWith("suspend")) { hasSuspend = true; hasSuspendLine = line.substring("suspend ".length()).replaceAll("\\(.*\\)", "").trim(); continue; } if (line.contains(" less to play.")) { hasLessToPlay = true; } if (line.contains(" more to play.")) { hasMoreToPlay = true; } if (line.contains("lifelink")) { hasLifelink = true; } if (line.contains("deathtouch")) { hasDeathtouch = true; } if (line.indexOf(lowerCard + " doesn't untap during") != -1) { properties.add("does-not-untap"); } if (line.indexOf("you may choose not to untap") != -1) { properties.add("may-not-untap"); } if (line.indexOf(lowerCard + " can't block") != -1) { properties.add("cannot-block"); } if (line.indexOf(lowerCard + " can't attack") != -1) { properties.add("cannot-attack"); } if (line.indexOf(lowerCard + " is unblockable.") != -1) properties.add("unblockable"); if (line.indexOf(lowerCard + " is indestructible.") != -1) properties.add("indestructible"); if (line.indexOf(lowerCard + " can't be countered.") != -1) properties.add("cannot-be-countered"); if (line.indexOf(lowerCard + " attacks each turn if able.") != -1) properties.add("attacks-if-able"); if (line.indexOf(lowerCard + " can't be blocked by walls.") != -1) properties.add("cannot-be-blocked-by-walls"); if (line.indexOf(lowerCard + " can block only creatures with flying") != -1) properties.add("block-only-flying"); lastLine = line; } cardText.append(" -->"); out.println("<?xml version='1.0'?>"); out.print("<card xmlns='"); out.println(IdConst.NAME_SPACE + "'"); out.print("\txmlns:xsi='"); out.print(XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI); out.println("'"); out.print("\txsi:schemaLocation='"); out.println(IdConst.NAME_SPACE + " ../../" + IdConst.TBS_XSD + "'"); out.println("\tname=\"" + cardName + "\">"); out.println("<rules-author-comment>Oracle2Xml generator " + IdConst.VERSION + "</rules-author-comment>\n"); out.println(cardText.toString()); out.println("\n\t<!-- COMPLETE THE CODE OF THIS CARD -->\n"); out.println("\t<init>"); out.println("\t\t<registers>"); if (manaCost != null) { if (isHybrid) { int a = 0; for (int i = 0; i < 6; i++) { if (manaCost[i] > 0) { a += manaCost[i]; if (i != 0) break; } } out.println("\t\t\t<register index='colorless' value='" + a + "'/>"); } else { for (int i = 6; i-- > 0;) { if (manaCost[i] > 0) { out.println("\t\t\t<register index='" + extractColor(i) + "' value='" + manaCost[i] + "'/>"); } } } } // power / toughness if (isCreature) { if (power.indexOf("*") != -1) { // power depends on ... out.println("\t\t\t<register index='power'>"); out.println("\t\t\t\t<!-- REPLACE THIS CODE -->"); out.println("\t\t\t\t<value>"); out.println("\t\t\t\t\t<counter restriction-zone='play'>"); out.println("\t\t\t\t\t\t<and>"); out.println("\t\t\t\t\t\t\t<has-idcard idcard='swamp'/>"); out.println("\t\t\t\t\t\t\t<controller player='you'/>"); out.println("\t\t\t\t\t\t</and>"); out.println("\t\t\t\t\t</counter>"); out.println("\t\t\t\t</value>"); out.println("\t\t\t</register>"); } else { out.println("\t\t\t<register index='power' value='" + power + "'/>"); } if (toughness.indexOf("*") != -1) { // toughness depends on ... out.println("\t\t\t<register index='toughness'>"); out.println("\t\t\t\t<!-- REPLACE THIS CODE -->"); out.println("\t\t\t\t<value>"); out.println("\t\t\t\t\t<counter restriction-zone='play'>"); out.println("\t\t\t\t\t\t<and>"); out.println("\t\t\t\t\t\t\t<has-idcard idcard='swamp'/>"); out.println("\t\t\t\t\t\t\t<controller player='you'/>"); out.println("\t\t\t\t\t\t</and>"); out.println("\t\t\t\t\t</counter>"); out.println("\t\t\t\t</value>"); out.println("\t\t\t</register>"); } else { out.println("\t\t\t<register index='toughness' value='" + toughness + "'/>"); } } out.println("\t\t</registers>"); // colors if (manaCost != null && manaCost.length > 0) { out.print("\t\t<colors>"); for (int i = manaCost.length - 1; i-- > 1;) { if (manaCost[i] > 0) { out.print(extractColor(i)); if (i > 0) { out.print(" "); } } } out.println("</colors>"); } // idcards out.print("\t\t<idcards>"); if (isTribal) out.print("tribal "); if (isPlaneswalker) out.print("planeswalker "); else if (isCreature && isArtifact) { out.print("artifact-creature "); } else if (isArtifact) out.print("artifact "); else if (isCreature) out.print("creature "); if (isNonBasicLand) { out.print("land "); } else if (isAura) { out.print("local-enchantment "); } else if (isEnchantWorld) { out.print("enchant-world "); } else if (isGlobalEnchant) { out.print("global-enchantment "); } else if (isInstant) { out.print("instant "); } else if (isSorcery) { out.print("sorcery "); } if (isSwamp) { out.print("swamp "); } if (isIsland) { out.print("island "); } if (isForest) { out.print("forest "); } if (isMountain) { out.print("mountain "); } if (isPlains) { out.print("plains "); } out.println("</idcards>"); // properties if (!properties.isEmpty()) { out.print("\t\t<properties>"); for (String property : properties) { out.print(property); out.print(" "); } out.println("</properties>"); } out.println("\t</init>"); if (!lineBuffer.isEmpty()) { line = lineBuffer.get(0); } if (hasFlashBack) { out.println("\t<actions>"); out.println("\t\t<action reference-name='main-effects'>"); /* * if (line.indexOf(':') != -1) { writeActions(out, * line.substring(line.indexOf(':') + 1), true); } */ writeActions(out, line, true, false); out.println( "\t\t\t\t<!-- PUT HERE EFFECTS OF THIS SPELL. THIS WILL BE INCLUDED TO FLASHBACK TOO -->"); out.println("\t\t</action>"); out.println("\t</actions>"); } // abilities out.println("\t<abilities>"); if (hasLifelink) out.println("\t\t<ability ref='lifelink'/>"); if (hasDeathtouch) out.println("\t\t<ability ref='deathtouch'/>"); if (hasSuspend) { out.println("\t\t<ability ref='cast-suspend'>"); out.println("\t\t\t<actions>"); writeCost(out, hasSuspendLine.substring(hasSuspendLine.indexOf("-") + 1), null); out.println("\t\t\t</actions>"); out.println("\t\t\t<actions>"); out.println("\t\t\t\t<repeat value='" + hasSuspendLine.charAt(0) + "'/>"); out.println("\t\t\t\t<add-object object-name='time'/>"); out.println("\t\t\t</actions>"); out.println("\t\t</ability>"); } if (isAura) { out.println("\t\t<ability ref='cast-enchant'/>"); } else if (isCreature || isGlobalEnchant || isEnchantWorld || isArtifact || isPlaneswalker) { if (hasAffinity) { out.println("\t\t<ability ref='cast-spell'>"); out.println("\t\t\t<actions>"); writeAffinity(out, hasAffinityLine); out.println("\t\t\t</actions>"); out.println("\t\t</ability>"); } else if (isHybrid) { int h, i1 = 0, i2 = 0, symbols = 0; for (h = 1; h < 6; h++) { if (manaCost[h] > 0) { if (i1 == 0) { i1 = h; symbols = manaCost[h]; } else i2 = h; } } for (h = 0; h <= symbols; h++) { out.println("\t\t<activated-ability playable='this' zone='hand'>"); out.println("\t\t\t<cost>"); out.print("\t\t\t\t<pay-mana "); if (manaCost[0] > 0) out.print("colorless='" + manaCost[0] + "' "); if (symbols - h > 0) out.print(extractColor(i1) + "='" + (symbols - h) + "' "); if (h > 0 && i2 > 0) out.print(extractColor(i2) + "='" + h + "'"); out.println("/>"); out.println("\t\t\t</cost>"); out.println("\t\t\t<effects>"); out.println("\t\t\t\t<action ref='put-in-play' />"); out.println("\t\t\t</effects>"); out.println("\t\t</activated-ability>"); } } else { out.println("\t\t<ability ref='cast-spell'/>"); } } else if (isNonBasicLand || isForest || isPlains || isIsland || isSwamp || isMountain) { out.println("\t\t<ability ref='cast-land'/>"); } if (hasForecast) { out.println("\t\t<ability ref='reset-forecast' />"); out.println("\t\t<ability ref='forecast'>"); out.println("\t\t\t<actions>"); writeCost(out, hasForecastLine, null); out.println("\t\t\t</actions>"); out.println("\t\t\t<actions>"); out.println("\t\t\t\t<!-- PUT HERE THE EFFECTS OF FORECAST -->"); out.println("\t\t\t</actions>"); out.println("\t\t</ability>"); } if (isInstant || isSorcery) { out.println("\t\t<activated-ability " + (hasBuyBack || hasFlashBack ? "reference-name='main-ability' " : "") + "playable='this' name='' zone='hand'>"); out.println("\t\t\t<cost>"); out.println("\t\t\t\t<pay-mana value='manacost'/>"); if (hasAffinity) writeAffinity(out, hasAffinityLine); writeXmanaCost(out, manaCost, false); if (hasFlashBack) { out.println( "\t\t\t\t<!-- PUT HERE THE COST OF THIS SPELL. THIS WILL NOT BE INCLUDED TO FLASHBACK COST -->"); out.println("\t\t\t</cost>"); out.println("\t\t\t<effects>"); out.println("\t\t\t\t<action ref='main-effects'/>"); out.println("\t\t\t\t<action ref='finish-spell'/>"); } else { if (line.indexOf("at the beginning of") != -1) { out.println("\t\t<create-ability>"); out.println("\t\t\t<!-- UPDATE PHASE NAME, TYPE and RESOLUTION -->"); out.println("\t\t\t<triggered-ability resolution='normal' zone='play'>"); out.println("\t\t\t\t<beginning-of-phase phase='upkeep'>"); out.println("\t\t\t\t\t<test ref='during-your-upkeep'/>"); out.println("\t\t\t\t</beginning-of-phase>"); out.println("\t\t\t\t<effects>"); writeActions(out, line, true, false); out.println("\t\t\t\t\t<!-- PUT HERE EFFECTS OF THIS DELAYED CARD -->"); out.println("\t\t\t\t\t<unregister-this/>"); out.println("\t\t\t\t</effects>"); out.println("\t\t\t</triggered-ability>"); out.println("\t\t</create-ability>"); } if (line.indexOf(':') != -1) { writeActions(out, line.substring(0, line.indexOf(':')), true, false); } else { line = writeCost(out, "", line); } if (line.indexOf("as an additional cost to play " + lowerCard) != -1) { writeActions(out, line.substring(("as an additional cost to play " + lowerCard).length()), true, false); line = ""; } out.println("\t\t\t\t<!-- PUT HERE THE COST OF THIS SPELL -->"); out.println("\t\t\t</cost>"); out.println("\t\t\t<effects>"); for (String subLine : lineBuffer) { writeActions(out, subLine, false, false); } out.println("\t\t\t\t<!-- PUT HERE EFFECTS OF THIS SPELL -->"); out.println("\t\t\t\t<action ref='finish-spell'/>"); } out.println("\t\t\t</effects>"); out.println("\t\t</activated-ability>"); } // Rampage if (hasRampage) { out.println("\t\t<ability ref='rampage" + hasRampageCount + "'/>"); } // Transmute if (hasTransmute) { out.println("\t\t<ability ref='transmute'>"); out.println("\t\t\t<actions>"); writeCost(out, hasTransmuteCost, null); out.println("\t\t\t</actions>"); out.println("\t\t</ability>"); } // Dredge if (hasDredge) { out.println("\t\t<ability ref='dredge" + hasDredgeCount + "'/>"); } // Haunt if (hasHaunt) { out.println("\t\t<ability ref='haunting'/>"); } // BloodThirst if (hasBloodThirst) { out.println("\t\t<ability ref='bloodthirst" + hasBloodThirstCount + "'/>"); } // Bushido if (hasBushido) { out.println("\t\t<ability ref='bushido" + hasBushidoCount + "-blocked'/>"); out.println("\t\t<ability ref='bushido" + hasBushidoCount + "-blocking'/>"); } // Buyback if (hasBuyBack) { line = hasBuyBackLine; out.println("\t\t<activated-ability playable='this' name='buyback%a' zone='hand'>"); out.println("\t\t\t<cost>"); out.println("\t\t\t\t<action ref='buyback'/>"); writeCost(out, line, null); out.println( "\t\t\t\t<!-- PUT HERE THE COST OF BUYBACK, AND COMPLETE THE MAIN ABILITY OF THE SPELL -->"); out.println("\t\t\t\t<insert-ability ref='main-ability'/>"); out.println("\t\t\t</cost>"); out.println("\t\t</activated-ability>"); } // Flashback if (hasFlashBack) { line = hasFlashBackLine; out.println("\t\t<activated-ability playable='this' name='flashback%a' zone='graveyard'>"); out.println("\t\t\t<cost>"); writeCost(out, line, null); out.println( "\t\t\t\t<!-- PUT HERE THE COST OF FLASHBACK, AND COMPLETE THE MAIN ABILITY OF THE SPELL -->"); out.println("\t\t\t</cost>"); out.println("\t\t\t<effects>"); out.println("\t\t\t\t<action ref='main-effects'/>"); out.println("\t\t\t\t<action ref='flashback'/>"); out.println("\t\t\t</effects>"); out.println("\t\t</activated-ability>"); } // Flanking if (hasFlanking) { out.println("\t\t<ability ref='flanking'/>"); } // Haunting if (hasHaunting) { out.println("\t\t<ability ref='haunting'/>"); } // Fading if (hasFading) { out.println("\t\t<ability ref='fading'/>"); } // Vanishing if (hasVanishing) { out.println("\t\t<ability ref='vanishing'/>"); } for (int k = 0; k < lineBuffer.size(); k++) { line = lineBuffer.get(k); // Equipment if (line.contains("equipped creature gets")) equipLine = line.substring(line.indexOf("gets ") + "gets ".length() + 1); if (line.indexOf("equip ") != -1 && isEquipment) { out.println("\t\t<activated-ability playable='this' zone='play'>"); out.println("\t\t\t<cost>"); writeCost(out, line.substring("equip".length()), null); out.println("\t\t\t\t<action ref='target-equipable-creature' />"); out.println("\t\t\t</cost>"); out.println("\t\t\t<effects>"); out.println("\t\t\t\t<action ref='equip' />"); out.println("\t\t\t</effects>"); out.println("\t\t</activated-ability>"); } // morph boolean hasMorph = false; if (line.indexOf("morph") == 0) { hasMorph = true; out.println("\t\t<ability ref='cast-morph'/>"); out.println("\t\t<ability ref='morph'>"); out.println("\t\t\t<actions>"); writeCost(out, line.substring("morph".length()), null); out.println("\t\t\t</actions>"); out.println("\t\t</ability>"); } if (line.indexOf(lowerCard + " comes into play tapped") != -1) { out.println("\t\t<ability ref='come-into-play-tapped'/>"); } if (!isInstant && !isSorcery && line.length() > 0 && line.indexOf(':') != -1) { // activated abilities out.println("\t\t<activated-ability playable='instant' name='' zone='play'>"); // test part if (hasMorph) { out.println("\t\t\t<test>"); out.println("\t\t\t\t<is-faceup card=\"me\"/>"); out.println("\t\t\t</test>"); } // 1) cost part out.println("\t\t\t<cost>"); out.println("\t\t\t\t<!-- PUT HERE THE COST OF THIS ABILITY -->"); writeCost(out, line.substring(0, line.indexOf(':')), line.substring(line.indexOf(':') + 1)); writeActions(out, line.substring(0, line.indexOf(':')), true, true); if (line.contains("play this ability only once each turn")) out.println("\t\t\t\t<action ref='use-once-each-turn'/>"); out.println("\t\t\t</cost>"); // 2) effect part out.println("\t\t\t<effects>"); out.println("\t\t\t\t<!-- PUT HERE EFFECTS OF THIS ABILITY -->"); if (line.indexOf(":") != -1) { writeActions(out, line.substring(line.indexOf(':') + 1), false, false); } else { writeActions(out, line, false, false); } out.println("\t\t\t</effects>"); out.println("\t\t</activated-ability>"); } if (line.indexOf("when") != -1 || line.indexOf("whenever") != -1) { if (line.indexOf("comes into play") != -1) { out.println("\t\t<triggered-ability zone='play'>"); out.println("\t\t\t<moved-card>"); out.println("\t\t\t\t<source-test>"); if (line.indexOf("when " + lowerCard + " comes into play") != -1) { out.println("\t\t\t\t\t<and>"); out.println("\t\t\t\t\t\t<is-this/>"); out.println("\t\t\t\t\t\t<not>"); out.println("\t\t\t\t\t\t\t<in-zone zone='play' card='tested'/>"); out.println("\t\t\t\t\t\t</not>"); out.println( "\t\t\t\t\t\t<!-- PUT HERE ADDITIONAL TEST ON CARD BEFORE IT GOES TO PLAY -->"); out.println("\t\t\t\t\t</and>"); } else { out.println( "\t\t\t\t<!-- PUT HERE ADDITIONAL TEST ON CARD BEFORE IT GOES TO PLAY -->"); } out.println("\t\t\t\t</source-test>"); out.println("\t\t\t\t<destination-test>"); out.println("\t\t\t\t\t<!-- PUT HERE ADDITIONAL TEST ON CARD WHEN IT GOES TO PLAY -->"); out.println("\t\t\t\t\t<in-zone zone='play' card='tested'/>"); out.println("\t\t\t\t</destination-test>"); out.println("\t\t\t</moved-card>"); } else if (line.indexOf(" is put into ") < line.indexOf("graveyard from ")) { out.println("\t\t<triggered-ability zone='graveyard'>"); out.println("\t\t\t<moved-card>"); out.println("\t\t\t\t<source-test>"); out.println("\t\t\t\t\t<!-- UPDATE TEST ON CARD BEFORE IT GOES TO GRAVEYARD -->"); out.println("\t\t\t\t\t<and>"); out.println("\t\t\t\t\t\t<is-this/>"); out.println("\t\t\t\t\t\t<in-zone zone='play' card='tested'/>"); out.println("\t\t\t\t\t</and>"); out.println("\t\t\t\t</source-test>"); out.println("\t\t\t\t<destination-test>"); out.println( "\t\t\t\t\t<!-- PUT HERE ADDITIONAL TEST ON CARD WHEN IT GOES TO GRAVEYARD -->"); out.println("\t\t\t\t\t<in-zone zone='graveyard' card='tested'/>"); out.println("\t\t\t\t</destination-test>"); out.println("\t\t\t</moved-card>"); } else if (line.indexOf(" leaves play") != -1) { out.println("\t\t<triggered-ability zone='graveyard'>"); out.println("\t\t\t<moved-card>"); out.println("\t\t\t\t<source-test>"); out.println("\t\t\t\t\t<!-- COMPLETE TEST ON CARD BEFORE IT LEAVE PLAY -->"); out.println("\t\t\t\t\t\t\t<in-zone zone='play' card='tested'/>"); out.println("\t\t\t\t</source-test>"); out.println("\t\t\t</moved-card>"); } else if (line.indexOf("blocks") != -1 || line.indexOf("becomes blocked") != -1) { out.println("\t\t<triggered-ability zone='play'>"); out.println("\t\t\t<declared-blocking>"); out.println("\t\t\t\t<blocking-test>"); out.println("\t\t\t\t\t<!-- COMPLETE THE TEST APPLIED ON BLOCKING CREATURE -->"); out.println("\t\t\t\t</blocking-test>"); out.println("\t\t\t\t<attacking-test>"); out.println("\t\t\t\t\t<!-- COMPLETE THE TEST APPLIED ON ATTACKING CREATURE -->"); out.println("\t\t\t\t</attacking-test>"); out.println("\t\t\t</declared-blocking>"); } else if (line.indexOf("attacks and isn't blocked") != -1) { out.println("\t\t<triggered-ability zone='play'>"); out.println("\t\t\t<modified-register operation='or' register='card' index='state'>"); out.println("\t\t\t\t<source-test>"); out.println("\t\t\t\t\t<!-- COMPLETE THE TEST APPLIED ON UNBLOCKED CREATURE -->"); out.println("\t\t\t\t\t<is-this/>"); out.println("\t\t\t\t</source-test>"); out.println("\t\t\t</modified-register>"); } else if (line.indexOf("deals combat damage to a player") != -1) { out.println("\t\t<triggered-ability zone='play'>"); out.println("\t\t\t<assigned-damage type='damage-combat'>"); out.println("\t\t\t\t<source-test>"); out.println("\t\t\t\t\t<is-this/>"); out.println("\t\t\t\t</source-test>"); out.println("\t\t\t\t<destination-test>"); out.println("\t\t\t\t\t<is-player/>"); out.println("\t\t\t\t</destination-test>"); out.println("\t\t\t</assigned-damage>"); } else if (line.indexOf("deals damage to") != -1) { out.println("\t\t<triggered-ability zone='play'>"); out.println("\t\t\t<assigned-damage type='damage-any'>"); out.println("\t\t\t\t<source-test>"); out.println("\t\t\t\t\t<is-this/>"); out.println("\t\t\t\t</source-test>"); out.println("\t\t\t\t<destination-test>"); out.println("\t\t\t\t\t<and>"); out.println("\t\t\t\t\t\t<not>"); out.println("\t\t\t\t\t\t<is-player/>"); out.println("\t\t\t\t\t\t</not>"); out.println("\t\t\t\t\t\t<has-idcard idcard='creature'/>"); out.println("\t\t\t\t\t</and>"); out.println("\t\t\t\t</destination-test>"); out.println("\t\t\t</assigned-damage>"); } else if (line.indexOf("deals combat damage to") != -1) { out.println("\t\t<triggered-ability zone='play'>"); out.println("\t\t\t<assigned-damage type='damage-combat'>"); out.println("\t\t\t\t<source-test>"); out.println("\t\t\t\t\t<is-this/>"); out.println("\t\t\t\t</source-test>"); out.println("\t\t\t\t<destination-test>"); out.println("\t\t\t\t\t<and>"); out.println("\t\t\t\t\t\t<not>"); out.println("\t\t\t\t\t\t\t<is-player/>"); out.println("\t\t\t\t\t\t</not>"); out.println("\t\t\t\t\t\t<has-idcard idcard='creature'/>"); out.println("\t\t\t\t\t</and>"); out.println("\t\t\t\t</destination-test>"); out.println("\t\t\t</assigned-damage>"); } else if (line.indexOf("deals damage to a player") != -1) { out.println("\t\t<triggered-ability zone='play'>"); out.println("\t\t\t<assigned-damage type='damage-any'>"); out.println("\t\t\t\t<source-test>"); out.println("\t\t\t\t\t<is-this/>"); out.println("\t\t\t\t</source-test>"); out.println("\t\t\t\t<destination-test>"); out.println("\t\t\t\t\t<is-player/>"); out.println("\t\t\t\t</destination-test>"); out.println("\t\t\t</assigned-damage>"); } else if (line.indexOf("becomes untapped") != -1) { out.println("\t\t<triggered-ability zone='play'>"); out.println("\t\t\t<become-untapped>"); out.println("\t\t\t\t<test>"); out.println("\t\t\t\t\t<!-- COMPLETE THE TEST APPLIED ON UNTAPPING CARD -->"); out.println("\t\t\t\t\t<is-this card='tested'/>"); out.println("\t\t\t\t</test>"); out.println("\t\t\t</become-untapped>"); } else if (line.indexOf("becomes tapped") != -1) { out.println("\t\t<triggered-ability zone='play'>"); out.println("\t\t\t<become-tapped>"); out.println("\t\t\t\t<test>"); out.println("\t\t\t\t\t<!-- COMPLETE THE TEST APPLIED ON TAPPING CARD -->"); out.println("\t\t\t\t\t<is-this card='tested'/>"); out.println("\t\t\t\t</test>"); out.println("\t\t\t</become-tapped>"); } else if (line.indexOf("attacks") != -1) { out.println("\t\t<triggered-ability zone='play'>"); out.println("\t\t\t<declared-blocking>"); out.println("\t\t\t\t<blocking-test>"); out.println("\t\t\t\t\t<is-this/>"); out.println("\t\t\t\t\t<!-- COMPLETE THE TEST APPLIED ON BLOCKING CREATURE -->"); out.println("\t\t\t\t</blocking-test>"); out.println("\t\t\t\t<attacking-test>"); out.println("\t\t\t\t\t<!-- COMPLETE THE TEST APPLIED ON ATTACKING CREATURE -->"); out.println("\t\t\t\t</attacking-test>"); out.println("\t\t\t</declared-blocking>"); } else if (line.indexOf("is turned face up") != -1) { out.println("\t\t<triggered-ability zone='play'>"); out.println("\t\t\t<faced-up>"); out.println("\t\t\t\t<test>"); out.println("\t\t\t\t<!-- UPDATE TEST ON FACED UP CARD -->"); out.println("\t\t\t\t\t<is-this />"); out.println("\t\t\t\t</test>"); out.println("\t\t\t</faced-up>"); } else if (line.indexOf("becomes the target of") != -1) { out.println("\t\t<triggered-ability zone='play'>"); out.println("\t\t\t<targeted>"); out.println("\t\t\t\t<source-test>"); out.println("\t\t\t\t<!-- UPDATE TEST ON SOURCE CARD -->"); out.println("\t\t\t\t</source-test>"); out.println("\t\t\t\t<destination-test>"); out.println("\t\t\t\t<!-- UPDATE TEST ON DESTINATION TARGET -->"); out.println("\t\t\t\t\t<is-this />"); out.println("\t\t\t\t</destination-test>"); out.println("\t\t\t</targeted>"); line.replaceFirst("becomes the target of", ""); } else { out.println("\t\t<triggered-ability zone='play'>"); out.println("\t\t\t\t\t<!-- UPDATE THE EVENT OF THIS TRIGGERED ABILITY -->"); out.println("\t\t\t<become-tapped>"); out.println("\t\t\t\t<test>"); out.println("\t\t\t\t\t<!-- COMPLETE THE TEST APPLIED ON TAPPING CARD -->"); out.println("\t\t\t\t\t<is-this card='tested'/>"); out.println("\t\t\t\t</test>"); out.println("\t\t\t</become-tapped>"); } if (line.contains("target")) { out.println("\t\t\t<cost>"); writeTarget(out, line, true); out.println("\t\t\t</cost>"); } out.println("\t\t\t<effects>"); writeActions(out, line, false, false); out.println("\t\t\t\t<!-- PUT HERE EFFECTS OF THIS TRIGGERED ABILITY -->"); out.println("\t\t\t</effects>"); out.println("\t\t</triggered-ability>"); } else if (line.indexOf("cycling") != -1) { // Cycling out.println("\t\t<ability ref='cycling'>"); out.println("\t\t\t<actions>"); writeCost(out, line.substring(line.indexOf("cycling") + "cycling".length()).trim(), null); out.println("\t\t\t</actions>"); out.println("\t\t</ability>"); } else if (line.indexOf("evoke") != -1) { // Evoke out.println( "\t\t<ability ref='evoke" + (properties.contains("flash") ? "-flash" : "") + "'>"); out.println("\t\t\t<actions>"); writeCost(out, line.substring(line.indexOf("evoke") + "evoke".length()).trim(), null); out.println("\t\t\t</actions>"); out.println("\t\t</ability>"); } else if (line.indexOf("madness") != -1) { // Madness out.println("\t\t<ability ref='madness'>"); out.println("\t\t\t<actions>"); writeCost(out, line.substring(line.indexOf("madness") + "madness".length()).trim(), null); out.println("\t\t\t</actions>"); out.println("\t\t</ability>"); } else if (line.indexOf("soulshift") != -1) { // Soulshift out.println("\t\t<ability ref='" + line.substring(line.indexOf("soulshift")).trim().replace(" ", "") + "'/>"); } else if (line.indexOf("echo") != -1) { // Echo out.println("\t\t<ability ref='echo'>"); out.println("\t\t\t<actions>"); writeCost(out, line.substring(line.indexOf("echo") + "echo".length()).trim(), null); out.println("\t\t\t</actions>"); out.println("\t\t</ability>"); } else if (line.indexOf("at the beginning of") != -1) { // at the beginning of if (!isInstant && !isSorcery) { // a simple triggered ability out.println("\t\t\t<!-- UPDATE PHASE NAME, TYPE and RESOLUTION -->"); out.println("\t\t<triggered-ability resolution='normal' zone='play'>"); out.println("\t\t\t<beginning-of-phase phase='upkeep'>"); out.println("\t\t\t\t<test ref='during-your-upkeep'/>"); out.println("\t\t\t</beginning-of-phase>"); if (line.indexOf("unless") != -1) { out.println("\t\t\t<cost>"); out.println("\t\t\t\t<choice cancel='false'>"); out.println("\t\t\t\t\t<either>"); out.println("\t\t\t\t\t\t<pay-mana colorless='1'/>"); out.println("\t\t\t\t\t</either>"); out.println("\t\t\t\t\t<either>"); out.println("\t\t\t\t\t\t<action ref='sacrifice-this'/>"); out.println("\t\t\t\t\t</either>"); out.println("\t\t\t\t</choice>"); out.println("\t\t\t</cost>"); } else { out.println("\t\t\t<effects>"); writeActions(out, line, false, false); out.println("\t\t\t\t<!-- PUT HERE EFFECTS OF THIS TRIGGERED ABILITY -->"); out.println("\t\t\t</effects>"); } out.println("\t\t</triggered-ability>"); } } else if (line.indexOf("cumulative upkeep") != -1) { // Cumulative upkeep out.println("\t\t<ability ref='cumulative-upkeep'/>"); out.println( "\t\t<triggered-ability resolution='normal' zone='play' name='cumulative-upkeep'>"); out.println("\t\t\t<beginning-of-phase phase='upkeep'>"); out.println("\t\t\t\t<test ref='during-your-upkeep'/>"); out.println("\t\t\t</beginning-of-phase>"); out.println("\t\t\t<cost>"); out.println("\t\t\t\t<choice cancel='false'>"); out.println("\t\t\t\t\t<either>"); out.println("\t\t\t\t\t\t<!-- PUT HERE THE ACTION(S) TO PAY -->"); out.println("\t\t\t\t\t\t<action ref='pay-life'>"); out.println("\t\t\t\t\t\t\t<value>"); out.println("\t\t\t\t\t\t\t\t<counter object-name='age' card='this'/>"); out.println("\t\t\t\t\t\t\t</value>"); out.println("\t\t\t\t\t\t</action>"); out.println("\t\t\t\t\t</either>"); out.println("\t\t\t\t\t<either>"); out.println("\t\t\t\t\t\t<action ref='sacrifice-this'/>"); out.println("\t\t\t\t\t</either>"); out.println("\t\t\t\t</choice>"); out.println("\t\t\t</cost>"); out.println("\t\t</triggered-ability>"); } } out.println("\t</abilities>"); // Fading or vanishing counter if (hasFading || hasVanishing || hasLessToPlay || hasMoreToPlay) { out.println("\t<modifiers>"); if (hasMoreToPlay) { out.println("\t\t<additional-cost-modifier linked='true'>"); out.println("\t\t\t<test>"); out.println("\t\t<!-- Complete the additional cost test -->"); out.println("\t\t\t</test>"); out.println("\t\t\t<cost>"); out.println("\t\t<!-- Update the additional cost amount -->"); out.println("\t\t\t\t<pay-mana colorless='1' />"); out.println("\t\t\t</cost>"); out.println("\t\t</additional-cost-modifier>"); } if (hasLessToPlay) { out.println("\t\t<additional-cost-modifier linked='true'>"); out.println("\t\t\t<test>"); out.println("\t\t<!-- Complete the cost reduction test -->"); out.println("\t\t\t</test>"); out.println("\t\t\t<cost>"); out.println("\t\t<!-- Update the cost reduction amount -->"); out.println("\t\t\t\t<pay-mana colorless='-1' />"); out.println("\t\t\t</cost>"); out.println("\t\t</additional-cost-modifier>"); } if (hasFading) { int fadingCounter = Integer.parseInt(hasFadingLine); if (fadingCounter == Integer.MIN_VALUE) { fadingCounter = 1; } for (int i = fadingCounter; i-- > 0;) { out.println("\t\t<object name='fade'/>"); } } if (hasVanishing) { int vanishingCounter; if (hasVanishingLine.length() != 0) vanishingCounter = Integer.parseInt(hasVanishingLine); else { vanishingCounter = 1; out.println("\t\t<!-- NEEDS CODE FOR NUMBER OF COUNTERS -->"); } if (vanishingCounter == Integer.MIN_VALUE) { vanishingCounter = 1; } for (int i = vanishingCounter; i-- > 0;) { out.println("\t\t<object name='time'/>"); } } out.println("\t</modifiers>"); } // Attachment if (isEquipment) { String pow = new String(); String tou = new String(); if (equipLine.length() > 0) { pow = equipLine.substring(0, equipLine.indexOf("/")); tou = equipLine.substring(equipLine.indexOf("/") + 2, equipLine.indexOf("/") + 3); } else { out.println("\t<!-- WRITE THE EQUIPMENT MODIFIERS -->"); } out.println("\t<attachment>"); out.println("\t\t<modifiers>"); if (!pow.contains("0")) out.println("\t\t\t<register-modifier index='power' operation='add' linked='true' value='" + pow + "' />"); if (!tou.contains("0")) out.println( "\t\t\t<register-modifier index='toughness' operation='add' linked='true' value='" + tou + "' />"); out.println("\t\t</modifiers>"); out.println("\t\t<valid-target ref='valid-creature-to-equip' />"); out.println("\t\t<valid-attachment ref='valid-equip-creature' />"); out.println("\t</attachment>"); } if (isAura) { out.print("\t<attachment"); if (isLocalEnchantCreature) { if (line.indexOf("you control enchanted creature") != -1) { out.println(" ref='control'/>"); out.println("\t<!-- Add the additional modifiers here-->"); } else if (line.startsWith("enchanted creature gets") || line.indexOf("enchanted creature has") != -1) { if (line.indexOf("gets") != -1) { String temp = line.substring(line.indexOf("gets")).split(" ")[1] .replaceFirst("[.,]", ""); out.print(" ref='" + temp); if (temp.indexOf("x") != -1) { out.println( "\t<!-- UPDATE X VALUE IN MODIFIERS, SEE CARD: Blanchwood Armor-->"); } } if (line.indexOf("has") != -1) { String property = line.substring(line.indexOf("has")).split(" ")[1] .replaceFirst("[.,]", ""); if (line.indexOf("gets") != -1) { out.println("'>"); out.println("\t\t<modifiers>"); out.println("\t\t\t<!-- UPDATE THE MODIFIER TYPE AND THE LINKED ATTRIBUTE -->"); out.println( "\t\t\t<property-modifier property='" + property + "' linked='true'/>"); out.println("\t\t</modifiers>"); out.println("\t</attachment>"); } else { out.println(" ref='" + property + "'/>"); } } else out.println("'/>"); } else { out.println(" ref='enchant-creature'/>"); } } else if (isLocalEnchantLand) { out.println(" ref='enchant-land'/>"); } else if (isLocalEnchantArtifact) { out.println(" ref='enchant-artifact'/>"); } else if (isLocalEnchantEnchantment) { out.println("\t\t<valid-target ref='valid-enchantment-to-enchant' />"); out.println("\t\t<valid-attachment ref='valid-enchant-enchantment' />"); } else if (isLocalEnchantCreatureArtifact) { out.println(" ref='enchant-artifact-creature'/>"); } else if (isLocalEnchantPermanent) { out.println(" ref='enchant'/>"); } } out.println("</card>"); IOUtils.closeQuietly(out); nbCard++; } } catch (FileNotFoundException e) { System.err.println("Error openning file '" + oracleFile + "' : " + e); } catch (IOException e) { System.err.println("IOError reading file '" + oracleFile + "' : " + e); } System.out.println("Success Parsing : " + nbCard + " card(s)"); }
From source file:org.betaconceptframework.astroboa.engine.definition.RepositoryEntityResolver.java
@Override public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException { if (XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI.equals(systemId) || XMLConstants.XML_NS_URI.equals(systemId) || CmsConstants.XML_SCHEMA_LOCATION.equals(systemId) || CmsConstants.XML_SCHEMA_DTD_LOCATION.equals(systemId)) { return entityResolverForBuiltInSchemas.resolveXmlSchemaRelatedToW3C(publicId, systemId); }/* w w w .j av a2s .c o m*/ byte[] schema = getSchema(systemId); if (schema == null) { return null; } InputSource is = new InputSource(new ByteArrayInputStream(schema)); is.setSystemId(systemId); is.setPublicId(publicId); return is; }
From source file:org.betaconceptframework.astroboa.engine.jcr.io.contenthandler.ImportContentHandler.java
private void importAttributes(Attributes atts) throws SAXException { if (atts != null && atts.getLength() > 0) { for (int i = 0; i < atts.getLength(); i++) { //Ignore attributes with specific namespaces String uri = atts.getURI(i); if (StringUtils.equals(uri, XMLConstants.XMLNS_ATTRIBUTE_NS_URI) || StringUtils.equals(uri, XMLConstants.XML_NS_URI) || StringUtils.equals(uri, XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI) || StringUtils.equals(uri, XMLConstants.W3C_XML_SCHEMA_NS_URI) || StringUtils.equals(uri, XMLConstants.W3C_XPATH_DATATYPE_NS_URI)) { continue; }/*from w ww . ja v a2 s . c o m*/ addAttributeToImportedEntity(atts.getLocalName(i), atts.getValue(i)); } } }
From source file:org.dataconservancy.ui.model.builder.xstream.BopConverterTest.java
private void setupXMLStrings() { COLLECTIONS_BOP_XML = "<" + E_BOP + " xmlns=\"" + XMLNS + "\"" + " xmlns:xsi=\"" + XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI + "\"\n" + " xsi:schemaLocation=\"" + XMLNS + "\">" + "<" + E_COLLECTIONS + ">\n" + " <" + E_COLLECTION + " " + E_ID + "=\"" + collectionWithData.getId() + "\">\n" + " <" + E_COL_ALTERNATE_IDS + ">\n" + " <" + E_COL_ALTERNATE_ID + ">" + collectionWithData.getAlternateIds().get(0) + "</" + E_COL_ALTERNATE_ID + ">\n" + " </" + E_COL_ALTERNATE_IDS + ">\n" + " <" + E_COL_TITLE + ">" + collectionWithData.getTitle() + "</" + E_COL_TITLE + ">\n" + " <" + E_COL_SUMMARY + ">" + collectionWithData.getSummary() + "</" + E_COL_SUMMARY + ">\n" + " <" + E_COL_CITABLE_LOCATOR + ">" + collectionWithData.getCitableLocator() + "</" + E_COL_CITABLE_LOCATOR + ">\n" + " <" + E_COL_CONTACT_INFOS + ">\n" + " <" + E_COL_CONTACT_INFO + ">\n" + " <" + E_CONTACT_NAME + ">" + contactInfoOne.getName() + "</" + E_CONTACT_NAME + ">\n" + " <" + E_CONTACT_ROLE + ">" + contactInfoOne.getRole() + "</" + E_CONTACT_ROLE + ">\n" + " <" + E_CONTACT_EMAIL + ">" + contactInfoOne.getEmailAddress() + "</" + E_CONTACT_EMAIL + ">\n" + " <" + E_CONTACT_PHONE + ">" + contactInfoOne.getPhoneNumber() + "</" + E_CONTACT_PHONE + ">\n" + " <" + E_CONTACT_ADDRESS + ">\n" + " <" + E_STREET_ADDRESS + ">" + contactInfoOne.getPhysicalAddress().getStreetAddress() + "</" + E_STREET_ADDRESS + ">\n" + " <" + E_CITY + ">" + contactInfoOne.getPhysicalAddress().getCity() + "</" + E_CITY + ">\n" + " <" + E_COUNTRY + ">" + contactInfoOne.getPhysicalAddress().getCountry() + "</" + E_COUNTRY + ">\n" + " </" + E_CONTACT_ADDRESS + ">\n" + " </" + E_COL_CONTACT_INFO + ">" + " <" + E_COL_CONTACT_INFO + ">\n" + " <" + E_CONTACT_NAME + ">" + contactInfoTwo.getName() + "</" + E_CONTACT_NAME + ">\n" + " <" + E_CONTACT_ROLE + ">" + contactInfoTwo.getRole() + "</" + E_CONTACT_ROLE + ">\n" + " <" + E_CONTACT_EMAIL + ">" + contactInfoTwo.getEmailAddress() + "</" + E_CONTACT_EMAIL + ">\n" + " <" + E_CONTACT_PHONE + ">" + contactInfoTwo.getPhoneNumber() + "</" + E_CONTACT_PHONE + ">\n" + " </" + E_COL_CONTACT_INFO + ">\n" + " </" + E_COL_CONTACT_INFOS + ">\n" + " <" + E_COL_CREATORS + ">\n" + " <" + E_COL_CREATOR + ">\n" + " <" + E_GIVEN_NAMES + ">" + creatorOne.getGivenNames() + "</" + E_GIVEN_NAMES + ">\n" + " <" + E_MIDDLE_NAMES + ">" + creatorOne.getMiddleNames() + "</" + E_MIDDLE_NAMES + ">\n" + " <" + E_FAMILY_NAMES + ">" + creatorOne.getFamilyNames() + "</" + E_FAMILY_NAMES + ">\n" + " <" + E_NAME_PREFIX + ">" + creatorOne.getPrefixes() + "</" + E_NAME_PREFIX + ">\n" + " <" + E_NAME_SUFFIX + ">" + creatorOne.getSuffixes() + "</" + E_NAME_SUFFIX + ">\n" + " </" + E_COL_CREATOR + ">\n" + " <" + E_COL_CREATOR + ">\n" + " <" + E_GIVEN_NAMES + ">" + creatorTwo.getGivenNames() + "</" + E_GIVEN_NAMES + ">\n" + " <" + E_MIDDLE_NAMES + ">" + creatorTwo.getMiddleNames() + "</" + E_MIDDLE_NAMES + ">\n" + " <" + E_FAMILY_NAMES + ">" + creatorTwo.getFamilyNames() + "</" + E_FAMILY_NAMES + ">\n" + " <" + E_NAME_PREFIX + ">" + creatorTwo.getPrefixes() + "</" + E_NAME_PREFIX + ">\n" + " <" + E_NAME_SUFFIX + ">" + creatorTwo.getSuffixes() + "</" + E_NAME_SUFFIX + ">\n" + " </" + E_COL_CREATOR + ">\n" + " </" + E_COL_CREATORS + ">\n" + " <" + E_COL_PUBLICATION_DATE + ">\n" + " <" + E_DATE + ">" + fmt.print(collectionWithData.getPublicationDate()) + "</" + E_DATE + ">\n" + " </" + E_COL_PUBLICATION_DATE + ">\n" + " <" + E_COL_DEPOSIT_DATE + ">\n" + " <" + E_DATE + ">" + fmt.print(collectionWithData.getDepositDate()) + "</" + E_DATE + ">\n" + " </" + E_COL_DEPOSIT_DATE + ">\n" + " <" + E_COL_DEPOSITOR + ">" + admin.getId() + "</" + E_COL_DEPOSITOR + ">\n" + " <" + E_COL_PARENT_PROJECT + ">" + projectOne.getId() + "</" + E_COL_PARENT_PROJECT + ">\n" + " </" + E_COLLECTION + ">\n" + " <" + E_COLLECTION + " " + E_ID + "=\"" + collectionNoData.getId() + "\">\n" + " <" + E_COL_TITLE + ">" + collectionNoData.getTitle() + "</" + E_COL_TITLE + ">\n" + " <" + E_COL_SUMMARY + ">" + collectionNoData.getSummary() + "</" + E_COL_SUMMARY + ">\n" + " <" + E_COL_PUBLICATION_DATE + ">\n" + " <" + E_DATE + ">" + fmt.print(collectionNoData.getPublicationDate()) + "</" + E_DATE + ">\n" + " </" + E_COL_PUBLICATION_DATE + ">\n" + " <" + E_COL_DEPOSIT_DATE + ">\n" + " <" + E_DATE + ">" + fmt.print(collectionNoData.getDepositDate()) + "</" + E_DATE + ">\n" + " </" + E_COL_DEPOSIT_DATE + ">\n" + " <" + E_COL_DEPOSITOR + ">" + admin.getId() + "</" + E_COL_DEPOSITOR + ">\n" + " <" + E_COL_PARENT_PROJECT + ">" + projectOne.getId() + "</" + E_COL_PARENT_PROJECT + ">\n" + " </" + E_COLLECTION + ">\n" + "</" + E_COLLECTIONS + ">\n" + "</" + E_BOP + ">"; PROJECTS_BOP_XML = "<" + E_BOP + " xmlns=\"" + XMLNS + "\"" + " xmlns:xsi=\"" + XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI + "\"\n" + " xsi:schemaLocation=\"" + XMLNS + "\">" + "<" + E_PROJECTS + ">\n" + "<" + E_PROJECT + " " + E_ID + "=\"" + projectOne.getId() + "\" xmlns=\"" + XMLNS + "\">\n" + " <" + E_NAME + ">" + projectOne.getName() + "</" + E_NAME + ">\n" + " <" + E_NUMBER + ">" + projectOne.getNumbers().get(0) + "</" + E_NUMBER + ">\n" + " <" + E_NUMBER + ">" + projectOne.getNumbers().get(1) + "</" + E_NUMBER + ">\n" + " <" + E_DESCRIPTION + ">" + projectOne.getDescription() + "</" + E_DESCRIPTION + ">\n" + " <" + E_PUBLISHER + ">" + projectOne.getPublisher() + "</" + E_PUBLISHER + ">\n" + " <" + E_STORAGEALLOCATED + ">" + projectOne.getStorageAllocated() + "</" + E_STORAGEALLOCATED + ">\n" + " <" + E_STORAGEUSED + ">" + projectOne.getStorageUsed() + "</" + E_STORAGEUSED + ">\n" + " <" + E_STARTDATE + ">\n" + " <" + E_DATE + ">" + fmt.print(projectOne.getStartDate()) + "</" + E_DATE + ">\n" + " </" + E_STARTDATE + ">\n" + " <" + E_ENDDATE + ">\n" + " <" + E_DATE + ">" + fmt.print(projectOne.getEndDate()) + "</" + E_DATE + ">\n" + " </" + E_ENDDATE + ">\n" + " <" + E_PRINCIPLEINVESTIGATORID + ">" + projectOne.getPis().get(0) + "</" + E_PRINCIPLEINVESTIGATORID + ">\n" + " <" + E_FUNDINGENTITY + ">" + projectOne.getFundingEntity() + "</" + E_FUNDINGENTITY + ">\n" + " </" + E_PROJECT + ">" + "<" + E_PROJECT + " " + E_ID + "=\"" + projectTwo.getId() + "\" xmlns=\"" + XMLNS + "\">\n" + " <" + E_NAME + ">" + projectTwo.getName() + "</" + E_NAME + ">\n" + " <" + E_NUMBER + ">" + projectTwo.getNumbers().get(0) + "</" + E_NUMBER + ">\n" + " <" + E_NUMBER + ">" + projectTwo.getNumbers().get(1) + "</" + E_NUMBER + ">\n" + " <" + E_DESCRIPTION + ">" + projectTwo.getDescription() + "</" + E_DESCRIPTION + ">\n" + " <" + E_PUBLISHER + ">" + projectTwo.getPublisher() + "</" + E_PUBLISHER + ">\n" + " <" + E_STORAGEALLOCATED + ">" + projectTwo.getStorageAllocated() + "</" + E_STORAGEALLOCATED + ">\n" + " <" + E_STORAGEUSED + ">" + projectTwo.getStorageUsed() + "</" + E_STORAGEUSED + ">\n" + " <" + E_STARTDATE + ">\n" + " <" + E_DATE + ">" + fmt.print(projectTwo.getStartDate()) + "</" + E_DATE + ">\n" + " </" + E_STARTDATE + ">\n" + " <" + E_ENDDATE + ">\n" + " <" + E_DATE + ">" + fmt.print(projectTwo.getEndDate()) + "</" + E_DATE + ">\n" + " </" + E_ENDDATE + ">\n" + " <" + E_PRINCIPLEINVESTIGATORID + ">" + projectTwo.getPis().get(0) + "</" + E_PRINCIPLEINVESTIGATORID + ">\n" + " <" + E_FUNDINGENTITY + ">" + projectTwo.getFundingEntity() + "</" + E_FUNDINGENTITY + ">\n" + " </" + E_PROJECT + ">" + "</" + E_PROJECTS + ">\n" + "</" + E_BOP + ">"; PERSONS_XML = "<" + E_BOP + " xmlns=\"" + XMLNS + "\"" + " xmlns:xsi=\"" + XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI + "\"\n" + " xsi:schemaLocation=\"" + XMLNS + "\">" + "<" + E_PERSONS + ">\n" + " <" + E_PERSON + " " + E_ID + "=\"" + user.getId() + "\" xmlns=\"" + XMLNS + "\">\n" + " <" + E_PREFIX + ">" + user.getPrefix() + "</" + E_PREFIX + ">\n" + " <" + E_FIRST_NAME + ">" + user.getFirstNames() + "</" + E_FIRST_NAME + ">\n" + " <" + E_MIDDLE_NAME + ">" + user.getMiddleNames() + "</" + E_MIDDLE_NAME + ">\n" + " <" + E_LAST_NAME + ">" + user.getLastNames() + "</" + E_LAST_NAME + ">\n" + " <" + E_SUFFIX + ">" + user.getSuffix() + "</" + E_SUFFIX + ">\n" + " <" + E_EMAIL_ADDRESS + ">" + user.getEmailAddress() + "</" + E_EMAIL_ADDRESS + ">\n" + " <" + E_PREFERRED_PUB_NAME + ">" + user.getPreferredPubName() + "</" + E_PREFERRED_PUB_NAME + ">\n" + " <" + E_BIO + ">" + user.getBio() + "</" + E_BIO + ">\n" + " <" + E_WEBSITE + ">" + user.getWebsite() + "</" + E_WEBSITE + ">\n" + " <" + E_CITY + ">" + user.getCity() + "</" + E_CITY + ">\n" + " <" + E_STATE + ">" + user.getState() + "</" + E_STATE + ">\n" + " <" + E_JOB_TITLE + ">" + user.getJobTitle() + "</" + E_JOB_TITLE + ">\n" + " <" + E_DEPARTMENT + ">" + user.getDepartment() + "</" + E_DEPARTMENT + ">\n" + " <" + E_INST_COMPANY + ">" + user.getInstCompany() + "</" + E_INST_COMPANY + ">\n" + " <" + E_INST_COMPANY_WEBSITE + ">" + user.getInstCompanyWebsite() + "</" + E_INST_COMPANY_WEBSITE + ">\n" + " <" + E_PHONE_NUMBER + ">" + user.getPhoneNumber() + "</" + E_PHONE_NUMBER + ">\n" + " <" + E_PASSWORD + ">" + user.getPassword() + "</" + E_PASSWORD + ">\n" + " <" + E_EXTERNAL_STORAGE_LINKED + ">" + Boolean.toString(user.isExternalStorageLinked()) + "</" + E_EXTERNAL_STORAGE_LINKED + ">\n" + " <" + E_DROPBOX_APP_KEY + ">" + user.getDropboxAppKey() + "</" + E_DROPBOX_APP_KEY + ">\n" + " <" + E_DROPBOX_APP_SECRET + ">" + user.getDropboxAppSecret() + "</" + E_DROPBOX_APP_SECRET + ">\n" + " <" + E_REGISTRATION_STATUS + ">" + user.getRegistrationStatus().name() + "</" + E_REGISTRATION_STATUS + ">\n" + " <" + E_READ_ONLY + ">" + user.getReadOnly() + "</" + E_READ_ONLY + ">\n" + " <" + E_ROLE + ">" + user.getRoles().get(0) + "</" + E_ROLE + ">\n" + " </" + E_PERSON + ">\n" + " <" + E_PERSON + " " + E_ID + "=\"" + admin.getId() + "\" xmlns=\"" + XMLNS + "\">\n" + " <" + E_PREFIX + ">" + admin.getPrefix() + "</" + E_PREFIX + ">\n" + " <" + E_FIRST_NAME + ">" + admin.getFirstNames() + "</" + E_FIRST_NAME + ">\n" + " <" + E_MIDDLE_NAME + ">" + admin.getMiddleNames() + "</" + E_MIDDLE_NAME + ">\n" + " <" + E_LAST_NAME + ">" + admin.getLastNames() + "</" + E_LAST_NAME + ">\n" + " <" + E_SUFFIX + ">" + admin.getSuffix() + "</" + E_SUFFIX + ">\n" + " <" + E_EMAIL_ADDRESS + ">" + admin.getEmailAddress() + "</" + E_EMAIL_ADDRESS + ">\n" + " <" + E_PREFERRED_PUB_NAME + ">" + admin.getPreferredPubName() + "</" + E_PREFERRED_PUB_NAME + ">\n" + " <" + E_BIO + ">" + admin.getBio() + "</" + E_BIO + ">\n" + " <" + E_WEBSITE + ">" + admin.getWebsite() + "</" + E_WEBSITE + ">\n" + " <" + E_CITY + ">" + admin.getCity() + "</" + E_CITY + ">\n" + " <" + E_STATE + ">" + admin.getState() + "</" + E_STATE + ">\n" + " <" + E_JOB_TITLE + ">" + admin.getJobTitle() + "</" + E_JOB_TITLE + ">\n" + " <" + E_DEPARTMENT + ">" + admin.getDepartment() + "</" + E_DEPARTMENT + ">\n" + " <" + E_INST_COMPANY + ">" + admin.getInstCompany() + "</" + E_INST_COMPANY + ">\n" + " <" + E_INST_COMPANY_WEBSITE + ">" + admin.getInstCompanyWebsite() + "</" + E_INST_COMPANY_WEBSITE + ">\n" + " <" + E_PHONE_NUMBER + ">" + admin.getPhoneNumber() + "</" + E_PHONE_NUMBER + ">\n" + " <" + E_PASSWORD + ">" + admin.getPassword() + "</" + E_PASSWORD + ">\n" + " <" + E_EXTERNAL_STORAGE_LINKED + ">" + Boolean.toString(admin.isExternalStorageLinked()) + "</" + E_EXTERNAL_STORAGE_LINKED + ">\n" + " <" + E_DROPBOX_APP_KEY + ">" + admin.getDropboxAppKey() + "</" + E_DROPBOX_APP_KEY + ">\n" + " <" + E_DROPBOX_APP_SECRET + ">" + admin.getDropboxAppSecret() + "</" + E_DROPBOX_APP_SECRET + ">\n" + " <" + E_REGISTRATION_STATUS + ">" + admin.getRegistrationStatus().name() + "</" + E_REGISTRATION_STATUS + ">\n" + " <" + E_READ_ONLY + ">" + admin.getReadOnly() + "</" + E_READ_ONLY + ">\n" + " <" + E_ROLE + ">" + admin.getRoles().get(0) + "</" + E_ROLE + ">\n" + " <" + E_ROLE + ">" + admin.getRoles().get(1) + "</" + E_ROLE + ">\n" + " </" + E_PERSON + ">\n" + "</" + E_PERSONS + ">\n" + "</" + E_BOP + ">"; FILE_XML1 = " <" + E_FILE + " " + DataFileConverter.E_ID + "=\"" + dataFileOne.getId() + "\" xmlns=\"" + XMLNS + "\">\n" + " <" + E_PARENT_ID + ">" + dataItemOne.getId() + "</" + E_PARENT_ID + ">\n" + " <" + DataFileConverter.E_NAME + ">" + dataFileOne.getName() + "</" + DataFileConverter.E_NAME + ">\n" + " <" + E_SOURCE + ">" + dataFileOne.getSource() + "</" + E_SOURCE + ">\n" + " <" + E_PATH + ">" + dataFileOne.getPath() + "</" + E_PATH + ">\n" + " <" + E_SIZE + ">" + String.valueOf(dataFileOne.getSize()) + "</" + E_SIZE + ">\n" + " </" + E_FILE + ">\n"; FILE_XML2 = " <" + E_FILE + " " + DataFileConverter.E_ID + "=\"" + dataFileTwo.getId() + "\" xmlns=\"" + XMLNS + "\">\n" + " <" + E_PARENT_ID + ">" + dataItemTwo.getId() + "</" + E_PARENT_ID + ">\n" + " <" + DataFileConverter.E_NAME + ">" + dataFileTwo.getName() + "</" + DataFileConverter.E_NAME + ">\n" + " <" + E_SOURCE + ">" + dataFileTwo.getSource() + "</" + E_SOURCE + ">\n" + " <" + E_PATH + ">" + dataFileTwo.getPath() + "</" + E_PATH + ">\n" + " <" + E_SIZE + ">" + String.valueOf(dataFileTwo.getSize()) + "</" + E_SIZE + ">\n" + " </" + E_FILE + ">\n"; DI_XML1 = " <" + E_DATA_ITEM + " " + DataItemConverter.E_ID + "=\"" + dataItemOne.getId() + "\" xmlns=\"" + XMLNS + "\">\n" + " <" + DataItemConverter.E_NAME + ">" + dataItemOne.getName() + "</" + DataItemConverter.E_NAME + ">\n" + " <" + DataItemConverter.E_DESCRIPTION + ">" + dataItemOne.getDescription() + "</" + DataItemConverter.E_DESCRIPTION + ">\n" + " <" + E_DEPOSITOR + " " + DataItemConverter.ATTR_REF + "=\"" + admin.getId() + "\" " + "/>\n" + " <" + E_DEPOSIT_DATE + ">\n" + " <" + E_DATE + ">" + fmt.print(dataItemOne.getDepositDate()) + "</" + E_DATE + ">\n" + " </" + E_DEPOSIT_DATE + ">\n" + " <" + E_FILES + ">\n" + FILE_XML1 + " </" + E_FILES + ">\n" + " <" + E_PARENT_ID + ">" + collectionWithData.getId() + "</" + E_PARENT_ID + ">\n" + " </" + E_DATA_ITEM + ">\n"; DI_XML2 = " <" + E_DATA_ITEM + " " + DataItemConverter.E_ID + "=\"" + dataItemTwo.getId() + "\" xmlns=\"" + XMLNS + "\">\n" + " <" + DataItemConverter.E_NAME + ">" + dataItemTwo.getName() + "</" + DataItemConverter.E_NAME + ">\n" + " <" + DataItemConverter.E_DESCRIPTION + ">" + dataItemTwo.getDescription() + "</" + DataItemConverter.E_DESCRIPTION + ">\n" + " <" + E_DEPOSITOR + " " + DataItemConverter.ATTR_REF + "=\"" + admin.getId() + "\" " + "/>\n" + " <" + E_DEPOSIT_DATE + ">\n" + " <" + E_DATE + ">" + fmt.print(dataItemTwo.getDepositDate()) + "</" + E_DATE + ">\n" + " </" + E_DEPOSIT_DATE + ">\n" + " <" + E_FILES + ">\n" + FILE_XML2 + " </" + E_FILES + ">\n" + " <" + E_PARENT_ID + ">" + collectionWithData.getId() + "</" + E_PARENT_ID + ">\n" + " </" + E_DATA_ITEM + ">\n"; DI_BOP_XML = "<" + E_BOP + " xmlns=\"" + XMLNS + "\"" + " xmlns:xsi=\"" + XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI + "\"\n" + " xsi:schemaLocation=\"" + XMLNS + "\">\n" + "<" + E_DATA_ITEMS + ">\n" + DI_XML1 + DI_XML2 + "</" + E_DATA_ITEMS + ">\n" + "</" + E_BOP + ">"; MF_XML_1 = " <" + E_METADATA_FILE + " " + MetadataFileConverter.E_ID + "=\"" + metadataFileOne.getId() + "\" xmlns=\"" + XMLNS + "\">\n" + " <" + E_PARENT_ID + ">" + metadataFileOne.getParentId() + "</" + E_PARENT_ID + ">\n" + " <" + E_SOURCE + ">" + metadataFileOne.getSource() + "</" + E_SOURCE + ">\n" + " <" + E_FORMAT + ">" + metadataFileOne.getFormat() + "</" + E_FORMAT + ">\n" + " <" + E_NAME + ">" + metadataFileOne.getName() + "</" + E_NAME + ">\n" + " <" + E_PATH + ">" + metadataFileOne.getPath() + "</" + E_PATH + ">\n" + " <" + E_METADATA_FORMAT + ">" + metadataFileOne.getMetadataFormatId() + "</" + E_METADATA_FORMAT + ">\n" + " </" + E_METADATA_FILE + ">\n"; MF_XML_2 = " <" + E_METADATA_FILE + " " + MetadataFileConverter.E_ID + "=\"" + metadataFileTwo.getId() + "\" xmlns=\"" + XMLNS + "\">\n" + " <" + E_PARENT_ID + ">" + metadataFileTwo.getParentId() + "</" + E_PARENT_ID + ">\n" + " <" + E_SOURCE + ">" + metadataFileTwo.getSource() + "</" + E_SOURCE + ">\n" + " <" + E_FORMAT + ">" + metadataFileTwo.getFormat() + "</" + E_FORMAT + ">\n" + " <" + E_NAME + ">" + metadataFileTwo.getName() + "</" + E_NAME + ">\n" + " <" + E_PATH + ">" + metadataFileTwo.getPath() + "</" + E_PATH + ">\n" + " <" + E_METADATA_FORMAT + ">" + metadataFileTwo.getMetadataFormatId() + "</" + E_METADATA_FORMAT + ">\n" + " </" + E_METADATA_FILE + ">\n"; MF_BOP_XML = "<" + E_BOP + " xmlns=\"" + XMLNS + "\"" + " xmlns:xsi=\"" + XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI + "\"\n" + " xsi:schemaLocation=\"" + XMLNS + "\">\n" + "<" + E_METADATA_FILES + ">\n" + MF_XML_1 + MF_XML_2 + "</" + E_METADATA_FILES + ">\n" + "</" + E_BOP + ">"; }
From source file:org.n52.wps.server.request.DescribeProcessRequest.java
/** * Actually serves the Request./*from ww w . j ava 2s. c om*/ * @throws ExceptionReport * @return Response The result of the computation */ public Response call() throws ExceptionReport { validate(); document = ProcessDescriptionsDocument.Factory.newInstance(); document.addNewProcessDescriptions(); XmlCursor c = document.newCursor(); c.toFirstChild(); c.toLastAttribute(); c.setAttributeText(new QName(XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI, "schemaLocation"), "http://www.opengis.net/wps/1.0.0 http://schemas.opengis.net/wps/1.0.0/wpsDescribeProcess_response.xsd"); String[] identifiers = getMapValue("identifier", true).split(","); document.getProcessDescriptions().setLang(WebProcessingService.DEFAULT_LANGUAGE); document.getProcessDescriptions().setService("WPS"); document.getProcessDescriptions().setVersion(Request.SUPPORTED_VERSION); if (identifiers.length == 1 && identifiers[0].equalsIgnoreCase("all")) { List<String> identifierList = RepositoryManager.getInstance().getAlgorithms(); identifiers = new String[identifierList.size()]; for (int i = 0; i < identifierList.size(); i++) { identifiers[i] = identifierList.get(i); } } // if(identifiers.length == 0){ // throw new ExceptionReport("No process identifier specified for describe process operation.", // ExceptionReport.MISSING_PARAMETER_VALUE, // "parameter: identifier"); // }else if (identifiers.length == 1) { if (identifiers[0] == null || identifiers[0].isEmpty()) { throw new ExceptionReport("Process description request with empty identifier.", ExceptionReport.INVALID_PARAMETER_VALUE, "identifier"); } } for (String algorithmName : identifiers) { if (!RepositoryManager.getInstance().containsAlgorithm(algorithmName)) { throw new ExceptionReport("Algorithm does not exist: " + algorithmName, ExceptionReport.INVALID_PARAMETER_VALUE, "identifier"); } ProcessDescriptionType description = RepositoryManager.getInstance() .getProcessDescription(algorithmName); document.getProcessDescriptions().addNewProcessDescription().set(description); } LOGGER.info("Handled Request successfully for: " + getMapValue("identifier", true)); return new DescribeProcessResponse(this); }
From source file:org.opencastproject.metadata.dublincore.DublinCoreCatalogImpl.java
/** * Creates a new dublin core metadata container. * /*from w w w . ja v a2 s. c o m*/ * @param id * the element identifier withing the package * @param uri * the document location * @param size * the catalog size in bytes * @param checksum * the catalog checksum */ protected DublinCoreCatalogImpl(String id, URI uri, MediaPackageElementFlavor flavor, long size, Checksum checksum) { super(id, flavor, uri, size, checksum, MimeTypes.XML); bindings.bindPrefix(XMLConstants.DEFAULT_NS_PREFIX, OPENCASTPROJECT_DUBLIN_CORE_NS_URI); bindings.bindPrefix("xsi", XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI); bindings.bindPrefix("dc", ELEMENTS_1_1_NS_URI); bindings.bindPrefix("dcterms", TERMS_NS_URI); bindings.bindPrefix("oc", OC_NS_URI); }
From source file:stroom.pipeline.server.filter.SchemaFilter.java
private void storeSchemaLocations(final String uri, final Attributes atts) throws SAXException { if (schemaValidation && schemaLocations == null && xmlSchemaCache != null) { schemaLocations = new TreeMap<>(); String schemaLocation = atts.getValue(XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI, SCHEMA_LOCATION); if (schemaLocation != null) { schemaLocation = MULTI_SPACE_PATTERN.matcher(schemaLocation).replaceAll(SPACE); schemaLocation = schemaLocation.trim(); final String[] locations = schemaLocation.split(SPACE); for (int i = 0; i < locations.length; i += 2) { if (i + 1 < locations.length) { final String namespace = locations[i]; final String schema = locations[i + 1]; schemaLocations.put(namespace, schema); }/*from w w w .j a v a 2 s . com*/ } } // Make sure all of the schema locations are valid. if (validateSchemaLocations(uri, schemaLocations, schemaConstraint)) { // Locations are valid so get a validator. validator = getValidator(); } } }