| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
package com.adobe.internal.xmp.impl; |
| 11 |
|
| 12 |
import java.util.List; |
| 13 |
import java.util.ArrayList; |
| 14 |
import java.util.Iterator; |
| 15 |
import org.w3c.dom.Attr; |
| 16 |
import org.w3c.dom.NamedNodeMap; |
| 17 |
import org.w3c.dom.Node; |
| 18 |
|
| 19 |
import com.adobe.internal.xmp.XMPConst; |
| 20 |
import com.adobe.internal.xmp.XMPError; |
| 21 |
import com.adobe.internal.xmp.XMPException; |
| 22 |
import com.adobe.internal.xmp.XMPMetaFactory; |
| 23 |
import com.adobe.internal.xmp.XMPSchemaRegistry; |
| 24 |
import com.adobe.internal.xmp.options.ParseOptions; |
| 25 |
import com.adobe.internal.xmp.options.PropertyOptions; |
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
public class ParseRDF implements XMPError, XMPConst |
| 36 |
{ |
| 37 |
|
| 38 |
public static final int RDFTERM_OTHER = 0; |
| 39 |
|
| 40 |
public static final int RDFTERM_RDF = 1; |
| 41 |
|
| 42 |
public static final int RDFTERM_ID = 2; |
| 43 |
|
| 44 |
public static final int RDFTERM_ABOUT = 3; |
| 45 |
|
| 46 |
public static final int RDFTERM_PARSE_TYPE = 4; |
| 47 |
|
| 48 |
public static final int RDFTERM_RESOURCE = 5; |
| 49 |
|
| 50 |
public static final int RDFTERM_NODE_ID = 6; |
| 51 |
|
| 52 |
public static final int RDFTERM_DATATYPE = 7; |
| 53 |
|
| 54 |
public static final int RDFTERM_DESCRIPTION = 8; |
| 55 |
|
| 56 |
public static final int RDFTERM_LI = 9; |
| 57 |
|
| 58 |
public static final int RDFTERM_ABOUT_EACH = 10; |
| 59 |
|
| 60 |
public static final int RDFTERM_ABOUT_EACH_PREFIX = 11; |
| 61 |
|
| 62 |
public static final int RDFTERM_BAG_ID = 12; |
| 63 |
|
| 64 |
public static final int RDFTERM_FIRST_CORE = RDFTERM_RDF; |
| 65 |
|
| 66 |
public static final int RDFTERM_LAST_CORE = RDFTERM_DATATYPE; |
| 67 |
|
| 68 |
public static final int RDFTERM_FIRST_SYNTAX = RDFTERM_FIRST_CORE; |
| 69 |
|
| 70 |
public static final int RDFTERM_LAST_SYNTAX = RDFTERM_LI; |
| 71 |
|
| 72 |
public static final int RDFTERM_FIRST_OLD = RDFTERM_ABOUT_EACH; |
| 73 |
|
| 74 |
public static final int RDFTERM_LAST_OLD = RDFTERM_BAG_ID; |
| 75 |
|
| 76 |
public static final String DEFAULT_PREFIX = "_dflt"; |
| 77 |
|
| 78 |
|
| 79 |
|
| 80 |
|
| 81 |
|
| 82 |
|
| 83 |
|
| 84 |
|
| 85 |
|
| 86 |
|
| 87 |
|
| 88 |
|
| 89 |
static XMPMetaImpl parse(Node xmlRoot, ParseOptions options) throws XMPException |
| 90 |
{ |
| 91 |
XMPMetaImpl xmp = new XMPMetaImpl(); |
| 92 |
rdf_RDF(xmp, xmlRoot, options); |
| 93 |
return xmp; |
| 94 |
} |
| 95 |
|
| 96 |
|
| 97 |
|
| 98 |
|
| 99 |
|
| 100 |
|
| 101 |
|
| 102 |
|
| 103 |
|
| 104 |
|
| 105 |
|
| 106 |
|
| 107 |
static void rdf_RDF(XMPMetaImpl xmp, Node rdfRdfNode, ParseOptions options) throws XMPException |
| 108 |
{ |
| 109 |
if (rdfRdfNode.hasAttributes()) |
| 110 |
{ |
| 111 |
rdf_NodeElementList (xmp, xmp.getRoot(), rdfRdfNode, options); |
| 112 |
} |
| 113 |
else |
| 114 |
{ |
| 115 |
throw new XMPException("Invalid attributes of rdf:RDF element", BADRDF); |
| 116 |
} |
| 117 |
} |
| 118 |
|
| 119 |
|
| 120 |
|
| 121 |
|
| 122 |
|
| 123 |
|
| 124 |
|
| 125 |
|
| 126 |
|
| 127 |
|
| 128 |
|
| 129 |
|
| 130 |
|
| 131 |
private static void rdf_NodeElementList(XMPMetaImpl xmp, XMPNode xmpParent, Node rdfRdfNode, ParseOptions options) |
| 132 |
throws XMPException |
| 133 |
{ |
| 134 |
for (int i = 0; i < rdfRdfNode.getChildNodes().getLength(); i++) |
| 135 |
{ |
| 136 |
Node child = rdfRdfNode.getChildNodes().item(i); |
| 137 |
|
| 138 |
if (!isWhitespaceNode(child)) |
| 139 |
{ |
| 140 |
rdf_NodeElement (xmp, xmpParent, child, true, options); |
| 141 |
} |
| 142 |
} |
| 143 |
} |
| 144 |
|
| 145 |
|
| 146 |
|
| 147 |
|
| 148 |
|
| 149 |
|
| 150 |
|
| 151 |
|
| 152 |
|
| 153 |
|
| 154 |
|
| 155 |
|
| 156 |
|
| 157 |
|
| 158 |
|
| 159 |
|
| 160 |
|
| 161 |
|
| 162 |
|
| 163 |
|
| 164 |
|
| 165 |
|
| 166 |
private static void rdf_NodeElement(XMPMetaImpl xmp, XMPNode xmpParent, Node xmlNode, |
| 167 |
boolean isTopLevel, ParseOptions options) throws XMPException |
| 168 |
{ |
| 169 |
int nodeTerm = getRDFTermKind (xmlNode); |
| 170 |
if (nodeTerm != RDFTERM_DESCRIPTION && nodeTerm != RDFTERM_OTHER) |
| 171 |
{ |
| 172 |
throw new XMPException("Node element must be rdf:Description or typed node", |
| 173 |
BADRDF); |
| 174 |
} |
| 175 |
else if (isTopLevel && nodeTerm == RDFTERM_OTHER) |
| 176 |
{ |
| 177 |
throw new XMPException("Top level typed node not allowed", BADXMP); |
| 178 |
} |
| 179 |
else |
| 180 |
{ |
| 181 |
rdf_NodeElementAttrs (xmp, xmpParent, xmlNode, isTopLevel, options); |
| 182 |
rdf_PropertyElementList (xmp, xmpParent, xmlNode, isTopLevel, options); |
| 183 |
} |
| 184 |
|
| 185 |
} |
| 186 |
|
| 187 |
|
| 188 |
|
| 189 |
|
| 190 |
|
| 191 |
|
| 192 |
|
| 193 |
|
| 194 |
|
| 195 |
|
| 196 |
|
| 197 |
|
| 198 |
|
| 199 |
|
| 200 |
|
| 201 |
|
| 202 |
|
| 203 |
|
| 204 |
|
| 205 |
|
| 206 |
|
| 207 |
|
| 208 |
|
| 209 |
|
| 210 |
private static void rdf_NodeElementAttrs(XMPMetaImpl xmp, XMPNode xmpParent, Node xmlNode, |
| 211 |
boolean isTopLevel, ParseOptions options) throws XMPException |
| 212 |
{ |
| 213 |
|
| 214 |
int exclusiveAttrs = 0; |
| 215 |
|
| 216 |
for (int i = 0; i < xmlNode.getAttributes().getLength(); i++) |
| 217 |
{ |
| 218 |
Node attribute = xmlNode.getAttributes().item(i); |
| 219 |
|
| 220 |
|
| 221 |
|
| 222 |
if ("xmlns".equals(attribute.getPrefix()) || |
| 223 |
(attribute.getPrefix() == null && "xmlns".equals(attribute.getNodeName()))) |
| 224 |
{ |
| 225 |
continue; |
| 226 |
} |
| 227 |
|
| 228 |
int attrTerm = getRDFTermKind(attribute); |
| 229 |
|
| 230 |
switch (attrTerm) |
| 231 |
{ |
| 232 |
case RDFTERM_ID: |
| 233 |
case RDFTERM_NODE_ID: |
| 234 |
case RDFTERM_ABOUT: |
| 235 |
if (exclusiveAttrs > 0) |
| 236 |
{ |
| 237 |
throw new XMPException("Mutally exclusive about, ID, nodeID attributes", |
| 238 |
BADRDF); |
| 239 |
} |
| 240 |
|
| 241 |
exclusiveAttrs++; |
| 242 |
|
| 243 |
if (isTopLevel && (attrTerm == RDFTERM_ABOUT)) |
| 244 |
{ |
| 245 |
|
| 246 |
|
| 247 |
|
| 248 |
|
| 249 |
if (xmpParent.getName() != null && xmpParent.getName().length() > 0) |
| 250 |
{ |
| 251 |
if (!xmpParent.getName().equals(attribute.getNodeValue())) |
| 252 |
{ |
| 253 |
throw new XMPException("Mismatched top level rdf:about values", |
| 254 |
BADXMP); |
| 255 |
} |
| 256 |
} |
| 257 |
else |
| 258 |
{ |
| 259 |
xmpParent.setName(attribute.getNodeValue()); |
| 260 |
} |
| 261 |
} |
| 262 |
break; |
| 263 |
|
| 264 |
case RDFTERM_OTHER: |
| 265 |
addChildNode(xmp, xmpParent, attribute, attribute.getNodeValue(), isTopLevel); |
| 266 |
break; |
| 267 |
|
| 268 |
default: |
| 269 |
throw new XMPException("Invalid nodeElement attribute", BADRDF); |
| 270 |
} |
| 271 |
|
| 272 |
} |
| 273 |
} |
| 274 |
|
| 275 |
|
| 276 |
|
| 277 |
|
| 278 |
|
| 279 |
|
| 280 |
|
| 281 |
|
| 282 |
|
| 283 |
|
| 284 |
|
| 285 |
|
| 286 |
|
| 287 |
private static void rdf_PropertyElementList(XMPMetaImpl xmp, XMPNode xmpParent, Node xmlParent, |
| 288 |
boolean isTopLevel, ParseOptions options) throws XMPException |
| 289 |
{ |
| 290 |
for (int i = 0; i < xmlParent.getChildNodes().getLength(); i++) |
| 291 |
{ |
| 292 |
Node currChild = xmlParent.getChildNodes().item(i); |
| 293 |
if (isWhitespaceNode(currChild)) |
| 294 |
{ |
| 295 |
continue; |
| 296 |
} |
| 297 |
else if (currChild.getNodeType() != Node.ELEMENT_NODE) |
| 298 |
{ |
| 299 |
throw new XMPException("Expected property element node not found", BADRDF); |
| 300 |
} |
| 301 |
else if ((xmpParent.getOptions().isArrayLimited() && (i > xmpParent.getOptions().getArrayElementsLimit()))) |
| 302 |
{ |
| 303 |
break; |
| 304 |
} |
| 305 |
else |
| 306 |
{ |
| 307 |
rdf_PropertyElement(xmp, xmpParent, currChild, isTopLevel, options); |
| 308 |
} |
| 309 |
} |
| 310 |
} |
| 311 |
|
| 312 |
|
| 313 |
|
| 314 |
|
| 315 |
|
| 316 |
|
| 317 |
|
| 318 |
|
| 319 |
|
| 320 |
|
| 321 |
|
| 322 |
|
| 323 |
|
| 324 |
|
| 325 |
|
| 326 |
|
| 327 |
|
| 328 |
|
| 329 |
|
| 330 |
|
| 331 |
|
| 332 |
|
| 333 |
|
| 334 |
|
| 335 |
|
| 336 |
|
| 337 |
|
| 338 |
|
| 339 |
|
| 340 |
|
| 341 |
|
| 342 |
|
| 343 |
|
| 344 |
|
| 345 |
|
| 346 |
|
| 347 |
|
| 348 |
|
| 349 |
|
| 350 |
|
| 351 |
|
| 352 |
|
| 353 |
|
| 354 |
|
| 355 |
|
| 356 |
|
| 357 |
|
| 358 |
|
| 359 |
|
| 360 |
|
| 361 |
|
| 362 |
|
| 363 |
|
| 364 |
|
| 365 |
|
| 366 |
|
| 367 |
|
| 368 |
|
| 369 |
|
| 370 |
|
| 371 |
|
| 372 |
|
| 373 |
private static void rdf_PropertyElement(XMPMetaImpl xmp, XMPNode xmpParent, Node xmlNode, |
| 374 |
boolean isTopLevel, ParseOptions options) throws XMPException |
| 375 |
{ |
| 376 |
int nodeTerm = getRDFTermKind (xmlNode); |
| 377 |
if (!isPropertyElementName(nodeTerm)) |
| 378 |
{ |
| 379 |
throw new XMPException("Invalid property element name", BADRDF); |
| 380 |
} |
| 381 |
|
| 382 |
|
| 383 |
NamedNodeMap attributes = xmlNode.getAttributes(); |
| 384 |
List nsAttrs = null; |
| 385 |
for (int i = 0; i < attributes.getLength(); i++) |
| 386 |
{ |
| 387 |
Node attribute = attributes.item(i); |
| 388 |
if ("xmlns".equals(attribute.getPrefix()) || |
| 389 |
(attribute.getPrefix() == null && "xmlns".equals(attribute.getNodeName()))) |
| 390 |
{ |
| 391 |
if (nsAttrs == null) |
| 392 |
{ |
| 393 |
nsAttrs = new ArrayList(); |
| 394 |
} |
| 395 |
nsAttrs.add(attribute.getNodeName()); |
| 396 |
} |
| 397 |
} |
| 398 |
if (nsAttrs != null) |
| 399 |
{ |
| 400 |
for (Iterator it = nsAttrs.iterator(); it.hasNext();) |
| 401 |
{ |
| 402 |
String ns = (String) it.next(); |
| 403 |
attributes.removeNamedItem(ns); |
| 404 |
} |
| 405 |
} |
| 406 |
|
| 407 |
|
| 408 |
if (attributes.getLength() > 3) |
| 409 |
{ |
| 410 |
|
| 411 |
rdf_EmptyPropertyElement(xmp, xmpParent, xmlNode, isTopLevel); |
| 412 |
} |
| 413 |
else |
| 414 |
{ |
| 415 |
|
| 416 |
|
| 417 |
|
| 418 |
|
| 419 |
for (int i = 0; i < attributes.getLength(); i++) |
| 420 |
{ |
| 421 |
Node attribute = attributes.item(i); |
| 422 |
String attrLocal = attribute.getLocalName(); |
| 423 |
String attrNS = attribute.getNamespaceURI(); |
| 424 |
String attrValue = attribute.getNodeValue(); |
| 425 |
if (!(XML_LANG.equals(attribute.getNodeName()) && |
| 426 |
!("ID".equals(attrLocal) && NS_RDF.equals(attrNS)))) |
| 427 |
{ |
| 428 |
if ("datatype".equals(attrLocal) && NS_RDF.equals(attrNS)) |
| 429 |
{ |
| 430 |
rdf_LiteralPropertyElement (xmp, xmpParent, xmlNode, isTopLevel); |
| 431 |
} |
| 432 |
else if (!("parseType".equals(attrLocal) && NS_RDF.equals(attrNS))) |
| 433 |
{ |
| 434 |
rdf_EmptyPropertyElement (xmp, xmpParent, xmlNode, isTopLevel); |
| 435 |
} |
| 436 |
else if ("Literal".equals(attrValue)) |
| 437 |
{ |
| 438 |
rdf_ParseTypeLiteralPropertyElement(); |
| 439 |
} |
| 440 |
else if ("Resource".equals(attrValue)) |
| 441 |
{ |
| 442 |
rdf_ParseTypeResourcePropertyElement(xmp, xmpParent, xmlNode, isTopLevel, options); |
| 443 |
} |
| 444 |
else if ("Collection".equals(attrValue)) |
| 445 |
{ |
| 446 |
rdf_ParseTypeCollectionPropertyElement(); |
| 447 |
} |
| 448 |
else |
| 449 |
{ |
| 450 |
rdf_ParseTypeOtherPropertyElement(); |
| 451 |
} |
| 452 |
|
| 453 |
return; |
| 454 |
} |
| 455 |
} |
| 456 |
|
| 457 |
|
| 458 |
|
| 459 |
|
| 460 |
if (xmlNode.hasChildNodes()) |
| 461 |
{ |
| 462 |
for (int i = 0; i < xmlNode.getChildNodes().getLength(); i++) |
| 463 |
{ |
| 464 |
Node currChild = xmlNode.getChildNodes().item(i); |
| 465 |
if (currChild.getNodeType() != Node.TEXT_NODE) |
| 466 |
{ |
| 467 |
rdf_ResourcePropertyElement (xmp, xmpParent, xmlNode, isTopLevel, options); |
| 468 |
return; |
| 469 |
} |
| 470 |
} |
| 471 |
|
| 472 |
rdf_LiteralPropertyElement (xmp, xmpParent, xmlNode, isTopLevel); |
| 473 |
} |
| 474 |
else |
| 475 |
{ |
| 476 |
rdf_EmptyPropertyElement (xmp, xmpParent, xmlNode, isTopLevel); |
| 477 |
} |
| 478 |
} |
| 479 |
} |
| 480 |
|
| 481 |
|
| 482 |
|
| 483 |
|
| 484 |
|
| 485 |
|
| 486 |
|
| 487 |
|
| 488 |
|
| 489 |
|
| 490 |
|
| 491 |
|
| 492 |
|
| 493 |
|
| 494 |
|
| 495 |
|
| 496 |
|
| 497 |
|
| 498 |
|
| 499 |
private static void rdf_ResourcePropertyElement(XMPMetaImpl xmp, XMPNode xmpParent, |
| 500 |
Node xmlNode, boolean isTopLevel, ParseOptions options) throws XMPException |
| 501 |
{ |
| 502 |
if (isTopLevel && "iX:changes".equals(xmlNode.getNodeName())) |
| 503 |
{ |
| 504 |
|
| 505 |
return; |
| 506 |
} |
| 507 |
|
| 508 |
XMPNode newCompound = addChildNode(xmp, xmpParent, xmlNode, "", isTopLevel); |
| 509 |
|
| 510 |
|
| 511 |
for (int i = 0; i < xmlNode.getAttributes().getLength(); i++) |
| 512 |
{ |
| 513 |
Node attribute = xmlNode.getAttributes().item(i); |
| 514 |
if ("xmlns".equals(attribute.getPrefix()) || |
| 515 |
(attribute.getPrefix() == null && "xmlns".equals(attribute.getNodeName()))) |
| 516 |
{ |
| 517 |
continue; |
| 518 |
} |
| 519 |
|
| 520 |
String attrLocal = attribute.getLocalName(); |
| 521 |
String attrNS = attribute.getNamespaceURI(); |
| 522 |
if (XML_LANG.equals(attribute.getNodeName())) |
| 523 |
{ |
| 524 |
addQualifierNode (newCompound, XML_LANG, attribute.getNodeValue()); |
| 525 |
} |
| 526 |
else if ("ID".equals(attrLocal) && NS_RDF.equals(attrNS)) |
| 527 |
{ |
| 528 |
continue; |
| 529 |
} |
| 530 |
else |
| 531 |
{ |
| 532 |
throw new XMPException( |
| 533 |
"Invalid attribute for resource property element", BADRDF); |
| 534 |
} |
| 535 |
} |
| 536 |
|
| 537 |
|
| 538 |
|
| 539 |
Node currChild = null; |
| 540 |
boolean found = false; |
| 541 |
int i; |
| 542 |
for (i = 0; i < xmlNode.getChildNodes().getLength(); i++) |
| 543 |
{ |
| 544 |
currChild = xmlNode.getChildNodes().item(i); |
| 545 |
if (!isWhitespaceNode(currChild)) |
| 546 |
{ |
| 547 |
if (currChild.getNodeType() == Node.ELEMENT_NODE && !found) |
| 548 |
{ |
| 549 |
boolean isRDF = NS_RDF.equals(currChild.getNamespaceURI()); |
| 550 |
String childLocal = currChild.getLocalName(); |
| 551 |
|
| 552 |
if (isRDF && "Bag".equals(childLocal)) |
| 553 |
{ |
| 554 |
newCompound.getOptions().setArray(true); |
| 555 |
} |
| 556 |
else if (isRDF && "Seq".equals(childLocal)) |
| 557 |
{ |
| 558 |
newCompound.getOptions().setArray(true).setArrayOrdered(true); |
| 559 |
} |
| 560 |
else if (isRDF && "Alt".equals(childLocal)) |
| 561 |
{ |
| 562 |
newCompound.getOptions().setArray(true).setArrayOrdered(true) |
| 563 |
.setArrayAlternate(true); |
| 564 |
} |
| 565 |
else |
| 566 |
{ |
| 567 |
newCompound.getOptions().setStruct(true); |
| 568 |
if (!isRDF && !"Description".equals(childLocal)) |
| 569 |
{ |
| 570 |
String typeName = currChild.getNamespaceURI(); |
| 571 |
if (typeName == null) |
| 572 |
{ |
| 573 |
throw new XMPException( |
| 574 |
"All XML elements must be in a namespace", BADXMP); |
| 575 |
} |
| 576 |
typeName += ':' + childLocal; |
| 577 |
addQualifierNode (newCompound, "rdf:type", typeName); |
| 578 |
} |
| 579 |
} |
| 580 |
|
| 581 |
Integer listLimit; |
| 582 |
|
| 583 |
if(newCompound.getOptions().isArray() && ((listLimit = options.getXMPNodesToLimit().get(newCompound.getName())) != null)) |
| 584 |
{ |
| 585 |
newCompound.getOptions().setArrayElementLimit(listLimit); |
| 586 |
} |
| 587 |
rdf_NodeElement (xmp, newCompound, currChild, false, options); |
| 588 |
|
| 589 |
if (newCompound.getHasValueChild()) |
| 590 |
{ |
| 591 |
fixupQualifiedNode (newCompound); |
| 592 |
} |
| 593 |
else if (newCompound.getOptions().isArrayAlternate()) |
| 594 |
{ |
| 595 |
XMPNodeUtils.detectAltText(newCompound); |
| 596 |
} |
| 597 |
|
| 598 |
found = true; |
| 599 |
} |
| 600 |
else if (found) |
| 601 |
{ |
| 602 |
|
| 603 |
throw new XMPException( |
| 604 |
"Invalid child of resource property element", BADRDF); |
| 605 |
} |
| 606 |
else |
| 607 |
{ |
| 608 |
throw new XMPException( |
| 609 |
"Children of resource property element must be XML elements", BADRDF); |
| 610 |
} |
| 611 |
} |
| 612 |
} |
| 613 |
|
| 614 |
if (!found) |
| 615 |
{ |
| 616 |
|
| 617 |
throw new XMPException("Missing child of resource property element", BADRDF); |
| 618 |
} |
| 619 |
} |
| 620 |
|
| 621 |
|
| 622 |
|
| 623 |
|
| 624 |
|
| 625 |
|
| 626 |
|
| 627 |
|
| 628 |
|
| 629 |
|
| 630 |
|
| 631 |
|
| 632 |
|
| 633 |
|
| 634 |
|
| 635 |
|
| 636 |
private static void rdf_LiteralPropertyElement(XMPMetaImpl xmp, XMPNode xmpParent, |
| 637 |
Node xmlNode, boolean isTopLevel) throws XMPException |
| 638 |
{ |
| 639 |
XMPNode newChild = addChildNode (xmp, xmpParent, xmlNode, null, isTopLevel); |
| 640 |
|
| 641 |
for (int i = 0; i < xmlNode.getAttributes().getLength(); i++) |
| 642 |
{ |
| 643 |
Node attribute = xmlNode.getAttributes().item(i); |
| 644 |
if ("xmlns".equals(attribute.getPrefix()) || |
| 645 |
(attribute.getPrefix() == null && "xmlns".equals(attribute.getNodeName()))) |
| 646 |
{ |
| 647 |
continue; |
| 648 |
} |
| 649 |
|
| 650 |
String attrNS = attribute.getNamespaceURI(); |
| 651 |
String attrLocal = attribute.getLocalName(); |
| 652 |
if (XML_LANG.equals(attribute.getNodeName())) |
| 653 |
{ |
| 654 |
addQualifierNode(newChild, XML_LANG, attribute.getNodeValue()); |
| 655 |
} |
| 656 |
else if (NS_RDF.equals(attrNS) && |
| 657 |
("ID".equals(attrLocal) || "datatype".equals(attrLocal))) |
| 658 |
{ |
| 659 |
continue; |
| 660 |
} |
| 661 |
else |
| 662 |
{ |
| 663 |
throw new XMPException( |
| 664 |
"Invalid attribute for literal property element", BADRDF); |
| 665 |
} |
| 666 |
} |
| 667 |
|
| 668 |
|
| 669 |
String textValue = ""; |
| 670 |
for (int i = 0; i < xmlNode.getChildNodes().getLength(); i++) |
| 671 |
{ |
| 672 |
Node child = xmlNode.getChildNodes().item(i); |
| 673 |
if (child.getNodeType() == Node.TEXT_NODE) |
| 674 |
{ |
| 675 |
textValue += child.getNodeValue(); |
| 676 |
} |
| 677 |
else |
| 678 |
{ |
| 679 |
throw new XMPException("Invalid child of literal property element", BADRDF); |
| 680 |
} |
| 681 |
} |
| 682 |
newChild.setValue(textValue); |
| 683 |
} |
| 684 |
|
| 685 |
|
| 686 |
|
| 687 |
|
| 688 |
|
| 689 |
|
| 690 |
|
| 691 |
|
| 692 |
|
| 693 |
|
| 694 |
|
| 695 |
private static void rdf_ParseTypeLiteralPropertyElement() throws XMPException |
| 696 |
{ |
| 697 |
throw new XMPException("ParseTypeLiteral property element not allowed", BADXMP); |
| 698 |
} |
| 699 |
|
| 700 |
|
| 701 |
|
| 702 |
|
| 703 |
|
| 704 |
|
| 705 |
|
| 706 |
|
| 707 |
|
| 708 |
|
| 709 |
|
| 710 |
|
| 711 |
|
| 712 |
|
| 713 |
|
| 714 |
|
| 715 |
|
| 716 |
|
| 717 |
|
| 718 |
private static void rdf_ParseTypeResourcePropertyElement(XMPMetaImpl xmp, XMPNode xmpParent, |
| 719 |
Node xmlNode, boolean isTopLevel, ParseOptions options) throws XMPException |
| 720 |
{ |
| 721 |
XMPNode newStruct = addChildNode (xmp, xmpParent, xmlNode, "", isTopLevel); |
| 722 |
|
| 723 |
newStruct.getOptions().setStruct(true); |
| 724 |
|
| 725 |
for (int i = 0; i < xmlNode.getAttributes().getLength(); i++) |
| 726 |
{ |
| 727 |
Node attribute = xmlNode.getAttributes().item(i); |
| 728 |
if ("xmlns".equals(attribute.getPrefix()) || |
| 729 |
(attribute.getPrefix() == null && "xmlns".equals(attribute.getNodeName()))) |
| 730 |
{ |
| 731 |
continue; |
| 732 |
} |
| 733 |
|
| 734 |
String attrLocal = attribute.getLocalName(); |
| 735 |
String attrNS = attribute.getNamespaceURI(); |
| 736 |
if (XML_LANG.equals(attribute.getNodeName())) |
| 737 |
{ |
| 738 |
addQualifierNode (newStruct, XML_LANG, attribute.getNodeValue()); |
| 739 |
} |
| 740 |
else if (NS_RDF.equals(attrNS) && |
| 741 |
("ID".equals(attrLocal) || "parseType".equals(attrLocal))) |
| 742 |
{ |
| 743 |
continue; |
| 744 |
|
| 745 |
} |
| 746 |
else |
| 747 |
{ |
| 748 |
throw new XMPException("Invalid attribute for ParseTypeResource property element", |
| 749 |
BADRDF); |
| 750 |
} |
| 751 |
} |
| 752 |
|
| 753 |
rdf_PropertyElementList (xmp, newStruct, xmlNode, false, options); |
| 754 |
|
| 755 |
if (newStruct.getHasValueChild()) |
| 756 |
{ |
| 757 |
fixupQualifiedNode (newStruct); |
| 758 |
} |
| 759 |
|
| 760 |
|
| 761 |
} |
| 762 |
|
| 763 |
|
| 764 |
|
| 765 |
|
| 766 |
|
| 767 |
|
| 768 |
|
| 769 |
|
| 770 |
|
| 771 |
|
| 772 |
|
| 773 |
private static void rdf_ParseTypeCollectionPropertyElement() throws XMPException |
| 774 |
{ |
| 775 |
throw new XMPException("ParseTypeCollection property element not allowed", BADXMP); |
| 776 |
} |
| 777 |
|
| 778 |
|
| 779 |
|
| 780 |
|
| 781 |
|
| 782 |
|
| 783 |
|
| 784 |
|
| 785 |
|
| 786 |
|
| 787 |
private static void rdf_ParseTypeOtherPropertyElement() throws XMPException |
| 788 |
{ |
| 789 |
throw new XMPException("ParseTypeOther property element not allowed", BADXMP); |
| 790 |
} |
| 791 |
|
| 792 |
|
| 793 |
|
| 794 |
|
| 795 |
|
| 796 |
|
| 797 |
|
| 798 |
|
| 799 |
|
| 800 |
|
| 801 |
|
| 802 |
|
| 803 |
|
| 804 |
|
| 805 |
|
| 806 |
|
| 807 |
|
| 808 |
|
| 809 |
|
| 810 |
|
| 811 |
|
| 812 |
|
| 813 |
|
| 814 |
|
| 815 |
|
| 816 |
|
| 817 |
|
| 818 |
|
| 819 |
|
| 820 |
|
| 821 |
|
| 822 |
|
| 823 |
|
| 824 |
|
| 825 |
|
| 826 |
|
| 827 |
|
| 828 |
|
| 829 |
|
| 830 |
|
| 831 |
|
| 832 |
|
| 833 |
|
| 834 |
|
| 835 |
|
| 836 |
|
| 837 |
private static void rdf_EmptyPropertyElement(XMPMetaImpl xmp, XMPNode xmpParent, Node xmlNode, |
| 838 |
boolean isTopLevel) throws XMPException |
| 839 |
{ |
| 840 |
boolean hasPropertyAttrs = false; |
| 841 |
boolean hasResourceAttr = false; |
| 842 |
boolean hasNodeIDAttr = false; |
| 843 |
boolean hasValueAttr = false; |
| 844 |
|
| 845 |
Node valueNode = null; |
| 846 |
|
| 847 |
if (xmlNode.hasChildNodes()) |
| 848 |
{ |
| 849 |
throw new XMPException( |
| 850 |
"Nested content not allowed with rdf:resource or property attributes", |
| 851 |
BADRDF); |
| 852 |
} |
| 853 |
|
| 854 |
|
| 855 |
for (int i = 0; i < xmlNode.getAttributes().getLength(); i++) |
| 856 |
{ |
| 857 |
Node attribute = xmlNode.getAttributes().item(i); |
| 858 |
if ("xmlns".equals(attribute.getPrefix()) || |
| 859 |
(attribute.getPrefix() == null && "xmlns".equals(attribute.getNodeName()))) |
| 860 |
{ |
| 861 |
continue; |
| 862 |
} |
| 863 |
|
| 864 |
int attrTerm = getRDFTermKind (attribute); |
| 865 |
|
| 866 |
switch (attrTerm) |
| 867 |
{ |
| 868 |
case RDFTERM_ID : |
| 869 |
|
| 870 |
break; |
| 871 |
|
| 872 |
case RDFTERM_RESOURCE : |
| 873 |
if (hasNodeIDAttr) |
| 874 |
{ |
| 875 |
throw new XMPException( |
| 876 |
"Empty property element can't have both rdf:resource and rdf:nodeID", |
| 877 |
BADRDF); |
| 878 |
} |
| 879 |
else if (hasValueAttr) |
| 880 |
{ |
| 881 |
throw new XMPException( |
| 882 |
"Empty property element can't have both rdf:value and rdf:resource", |
| 883 |
BADXMP); |
| 884 |
} |
| 885 |
|
| 886 |
hasResourceAttr = true; |
| 887 |
if (!hasValueAttr) |
| 888 |
{ |
| 889 |
valueNode = attribute; |
| 890 |
} |
| 891 |
break; |
| 892 |
|
| 893 |
case RDFTERM_NODE_ID: |
| 894 |
if (hasResourceAttr) |
| 895 |
{ |
| 896 |
throw new XMPException( |
| 897 |
"Empty property element can't have both rdf:resource and rdf:nodeID", |
| 898 |
BADRDF); |
| 899 |
} |
| 900 |
hasNodeIDAttr = true; |
| 901 |
break; |
| 902 |
|
| 903 |
case RDFTERM_OTHER: |
| 904 |
if ("value".equals(attribute.getLocalName()) |
| 905 |
&& NS_RDF.equals(attribute.getNamespaceURI())) |
| 906 |
{ |
| 907 |
if (hasResourceAttr) |
| 908 |
{ |
| 909 |
throw new XMPException( |
| 910 |
"Empty property element can't have both rdf:value and rdf:resource", |
| 911 |
BADXMP); |
| 912 |
} |
| 913 |
hasValueAttr = true; |
| 914 |
valueNode = attribute; |
| 915 |
} |
| 916 |
else if (!XML_LANG.equals(attribute.getNodeName())) |
| 917 |
{ |
| 918 |
hasPropertyAttrs = true; |
| 919 |
} |
| 920 |
break; |
| 921 |
|
| 922 |
default: |
| 923 |
throw new XMPException("Unrecognized attribute of empty property element", |
| 924 |
BADRDF); |
| 925 |
} |
| 926 |
} |
| 927 |
|
| 928 |
|
| 929 |
|
| 930 |
|
| 931 |
|
| 932 |
|
| 933 |
|
| 934 |
XMPNode childNode = addChildNode(xmp, xmpParent, xmlNode, "", isTopLevel); |
| 935 |
boolean childIsStruct = false; |
| 936 |
|
| 937 |
if (hasValueAttr || hasResourceAttr) |
| 938 |
{ |
| 939 |
childNode.setValue(valueNode != null ? valueNode.getNodeValue() : ""); |
| 940 |
if (!hasValueAttr) |
| 941 |
{ |
| 942 |
|
| 943 |
childNode.getOptions().setURI(true); |
| 944 |
} |
| 945 |
} |
| 946 |
else if (hasPropertyAttrs) |
| 947 |
{ |
| 948 |
childNode.getOptions().setStruct(true); |
| 949 |
childIsStruct = true; |
| 950 |
} |
| 951 |
|
| 952 |
for (int i = 0; i < xmlNode.getAttributes().getLength(); i++) |
| 953 |
{ |
| 954 |
Node attribute = xmlNode.getAttributes().item(i); |
| 955 |
if (attribute == valueNode || |
| 956 |
"xmlns".equals(attribute.getPrefix()) || |
| 957 |
(attribute.getPrefix() == null && "xmlns".equals(attribute.getNodeName()))) |
| 958 |
{ |
| 959 |
continue; |
| 960 |
} |
| 961 |
|
| 962 |
int attrTerm = getRDFTermKind (attribute); |
| 963 |
|
| 964 |
switch (attrTerm) |
| 965 |
{ |
| 966 |
case RDFTERM_ID : |
| 967 |
case RDFTERM_NODE_ID : |
| 968 |
break; |
| 969 |
|
| 970 |
case RDFTERM_RESOURCE : |
| 971 |
addQualifierNode(childNode, "rdf:resource", attribute.getNodeValue()); |
| 972 |
break; |
| 973 |
|
| 974 |
case RDFTERM_OTHER : |
| 975 |
if (!childIsStruct) |
| 976 |
{ |
| 977 |
addQualifierNode( |
| 978 |
childNode, attribute.getNodeName(), attribute.getNodeValue()); |
| 979 |
} |
| 980 |
else if (XML_LANG.equals(attribute.getNodeName())) |
| 981 |
{ |
| 982 |
addQualifierNode (childNode, XML_LANG, attribute.getNodeValue()); |
| 983 |
} |
| 984 |
else |
| 985 |
{ |
| 986 |
addChildNode (xmp, childNode, attribute, attribute.getNodeValue(), false); |
| 987 |
} |
| 988 |
break; |
| 989 |
|
| 990 |
default : |
| 991 |
throw new XMPException("Unrecognized attribute of empty property element", |
| 992 |
BADRDF); |
| 993 |
} |
| 994 |
|
| 995 |
} |
| 996 |
} |
| 997 |
|
| 998 |
|
| 999 |
|
| 1000 |
|
| 1001 |
|
| 1002 |
|
| 1003 |
|
| 1004 |
|
| 1005 |
|
| 1006 |
|
| 1007 |
|
| 1008 |
|
| 1009 |
|
| 1010 |
private static XMPNode addChildNode(XMPMetaImpl xmp, XMPNode xmpParent, Node xmlNode, |
| 1011 |
String value, boolean isTopLevel) throws XMPException |
| 1012 |
{ |
| 1013 |
XMPSchemaRegistry registry = XMPMetaFactory.getSchemaRegistry(); |
| 1014 |
String namespace = xmlNode.getNamespaceURI(); |
| 1015 |
String childName; |
| 1016 |
if (namespace != null) |
| 1017 |
{ |
| 1018 |
if (NS_DC_DEPRECATED.equals(namespace)) |
| 1019 |
{ |
| 1020 |
|
| 1021 |
|
| 1022 |
namespace = NS_DC; |
| 1023 |
} |
| 1024 |
|
| 1025 |
String prefix = registry.getNamespacePrefix(namespace); |
| 1026 |
if (prefix == null) |
| 1027 |
{ |
| 1028 |
prefix = xmlNode.getPrefix() != null ? xmlNode.getPrefix() : DEFAULT_PREFIX; |
| 1029 |
prefix = registry.registerNamespace(namespace, prefix); |
| 1030 |
} |
| 1031 |
childName = prefix + xmlNode.getLocalName(); |
| 1032 |
} |
| 1033 |
else |
| 1034 |
{ |
| 1035 |
throw new XMPException( |
| 1036 |
"XML namespace required for all elements and attributes", BADRDF); |
| 1037 |
} |
| 1038 |
|
| 1039 |
|
| 1040 |
|
| 1041 |
PropertyOptions childOptions = new PropertyOptions(); |
| 1042 |
boolean isAlias = false; |
| 1043 |
if (isTopLevel) |
| 1044 |
{ |
| 1045 |
|
| 1046 |
|
| 1047 |
XMPNode schemaNode = XMPNodeUtils.findSchemaNode(xmp.getRoot(), namespace, |
| 1048 |
DEFAULT_PREFIX, true); |
| 1049 |
schemaNode.setImplicit(false); |
| 1050 |
|
| 1051 |
|
| 1052 |
|
| 1053 |
xmpParent = schemaNode; |
| 1054 |
|
| 1055 |
|
| 1056 |
|
| 1057 |
if (registry.findAlias(childName) != null) |
| 1058 |
{ |
| 1059 |
isAlias = true; |
| 1060 |
xmp.getRoot().setHasAliases(true); |
| 1061 |
schemaNode.setHasAliases(true); |
| 1062 |
} |
| 1063 |
} |
| 1064 |
|
| 1065 |
|
| 1066 |
|
| 1067 |
boolean isArrayItem = isNumberedArrayItemName(childName); |
| 1068 |
|
| 1069 |
boolean isValueNode = "rdf:value".equals(childName); |
| 1070 |
|
| 1071 |
|
| 1072 |
XMPNode newChild = new XMPNode( |
| 1073 |
childName, value, childOptions); |
| 1074 |
newChild.setAlias(isAlias); |
| 1075 |
|
| 1076 |
|
| 1077 |
if (!isValueNode) |
| 1078 |
{ |
| 1079 |
xmpParent.addChild(newChild); |
| 1080 |
} |
| 1081 |
else |
| 1082 |
{ |
| 1083 |
xmpParent.addChild(1, newChild); |
| 1084 |
} |
| 1085 |
|
| 1086 |
|
| 1087 |
if (isValueNode) |
| 1088 |
{ |
| 1089 |
if (isTopLevel || !xmpParent.getOptions().isStruct()) |
| 1090 |
{ |
| 1091 |
throw new XMPException("Misplaced rdf:value element", BADRDF); |
| 1092 |
} |
| 1093 |
xmpParent.setHasValueChild(true); |
| 1094 |
} |
| 1095 |
|
| 1096 |
boolean isParentArray = xmpParent.getOptions().isArray(); |
| 1097 |
|
| 1098 |
if (isParentArray && isArrayItem) |
| 1099 |
{ |
| 1100 |
newChild.setName(ARRAY_ITEM_NAME); |
| 1101 |
} |
| 1102 |
else if (!isParentArray && isArrayItem) |
| 1103 |
{ |
| 1104 |
throw new XMPException("Misplaced rdf:li element", BADRDF); |
| 1105 |
} |
| 1106 |
else if (isParentArray && !isArrayItem) |
| 1107 |
{ |
| 1108 |
throw new XMPException("Arrays cannot have arbitrary child names", BADRDF); |
| 1109 |
} |
| 1110 |
|
| 1111 |
return newChild; |
| 1112 |
} |
| 1113 |
|
| 1114 |
|
| 1115 |
|
| 1116 |
|
| 1117 |
|
| 1118 |
|
| 1119 |
|
| 1120 |
|
| 1121 |
|
| 1122 |
|
| 1123 |
|
| 1124 |
|
| 1125 |
private static XMPNode addQualifierNode(XMPNode xmpParent, String name, String value) |
| 1126 |
throws XMPException |
| 1127 |
{ |
| 1128 |
boolean isLang = XML_LANG.equals(name); |
| 1129 |
|
| 1130 |
XMPNode newQual = null; |
| 1131 |
|
| 1132 |
|
| 1133 |
newQual = new XMPNode(name, isLang ? Utils.normalizeLangValue(value) : value, null); |
| 1134 |
xmpParent.addQualifier(newQual); |
| 1135 |
|
| 1136 |
return newQual; |
| 1137 |
} |
| 1138 |
|
| 1139 |
|
| 1140 |
|
| 1141 |
|
| 1142 |
|
| 1143 |
|
| 1144 |
|
| 1145 |
|
| 1146 |
|
| 1147 |
|
| 1148 |
|
| 1149 |
|
| 1150 |
private static void fixupQualifiedNode(XMPNode xmpParent) throws XMPException |
| 1151 |
{ |
| 1152 |
assert xmpParent.getOptions().isStruct() && xmpParent.hasChildren(); |
| 1153 |
|
| 1154 |
XMPNode valueNode = xmpParent.getChild(1); |
| 1155 |
assert "rdf:value".equals(valueNode.getName()); |
| 1156 |
|
| 1157 |
|
| 1158 |
|
| 1159 |
|
| 1160 |
|
| 1161 |
|
| 1162 |
|
| 1163 |
|
| 1164 |
if (valueNode.getOptions().getHasLanguage()) |
| 1165 |
{ |
| 1166 |
if (xmpParent.getOptions().getHasLanguage()) |
| 1167 |
{ |
| 1168 |
throw new XMPException("Redundant xml:lang for rdf:value element", |
| 1169 |
BADXMP); |
| 1170 |
} |
| 1171 |
XMPNode langQual = valueNode.getQualifier(1); |
| 1172 |
valueNode.removeQualifier(langQual); |
| 1173 |
xmpParent.addQualifier(langQual); |
| 1174 |
} |
| 1175 |
|
| 1176 |
|
| 1177 |
for (int i = 1; i <= valueNode.getQualifierLength(); i++) |
| 1178 |
{ |
| 1179 |
XMPNode qualifier = valueNode.getQualifier(i); |
| 1180 |
xmpParent.addQualifier(qualifier); |
| 1181 |
} |
| 1182 |
|
| 1183 |
|
| 1184 |
|
| 1185 |
|
| 1186 |
for (int i = 2; i <= xmpParent.getChildrenLength(); i++) |
| 1187 |
{ |
| 1188 |
XMPNode qualifier = xmpParent.getChild(i); |
| 1189 |
xmpParent.addQualifier(qualifier); |
| 1190 |
} |
| 1191 |
|
| 1192 |
|
| 1193 |
|
| 1194 |
assert xmpParent.getOptions().isStruct() || xmpParent.getHasValueChild(); |
| 1195 |
|
| 1196 |
xmpParent.setHasValueChild(false); |
| 1197 |
xmpParent.getOptions().setStruct(false); |
| 1198 |
xmpParent.getOptions().mergeWith(valueNode.getOptions()); |
| 1199 |
xmpParent.setValue(valueNode.getValue()); |
| 1200 |
|
| 1201 |
xmpParent.removeChildren(); |
| 1202 |
for (Iterator it = valueNode.iterateChildren(); it.hasNext();) |
| 1203 |
{ |
| 1204 |
XMPNode child = (XMPNode) it.next(); |
| 1205 |
xmpParent.addChild(child); |
| 1206 |
} |
| 1207 |
} |
| 1208 |
|
| 1209 |
|
| 1210 |
|
| 1211 |
|
| 1212 |
|
| 1213 |
|
| 1214 |
|
| 1215 |
|
| 1216 |
private static boolean isWhitespaceNode(Node node) |
| 1217 |
{ |
| 1218 |
if (node.getNodeType() != Node.TEXT_NODE) |
| 1219 |
{ |
| 1220 |
return false; |
| 1221 |
} |
| 1222 |
|
| 1223 |
String value = node.getNodeValue(); |
| 1224 |
for (int i = 0; i < value.length(); i++) |
| 1225 |
{ |
| 1226 |
if (!Character.isWhitespace(value.charAt(i))) |
| 1227 |
{ |
| 1228 |
return false; |
| 1229 |
} |
| 1230 |
} |
| 1231 |
|
| 1232 |
return true; |
| 1233 |
} |
| 1234 |
|
| 1235 |
|
| 1236 |
|
| 1237 |
|
| 1238 |
|
| 1239 |
|
| 1240 |
|
| 1241 |
|
| 1242 |
|
| 1243 |
private static boolean isPropertyElementName(int term) |
| 1244 |
{ |
| 1245 |
if (term == RDFTERM_DESCRIPTION || isOldTerm(term)) |
| 1246 |
{ |
| 1247 |
return false; |
| 1248 |
} |
| 1249 |
else |
| 1250 |
{ |
| 1251 |
return (!isCoreSyntaxTerm(term)); |
| 1252 |
} |
| 1253 |
} |
| 1254 |
|
| 1255 |
|
| 1256 |
|
| 1257 |
|
| 1258 |
|
| 1259 |
|
| 1260 |
|
| 1261 |
|
| 1262 |
|
| 1263 |
private static boolean isOldTerm(int term) |
| 1264 |
{ |
| 1265 |
return RDFTERM_FIRST_OLD <= term && term <= RDFTERM_LAST_OLD; |
| 1266 |
} |
| 1267 |
|
| 1268 |
|
| 1269 |
|
| 1270 |
|
| 1271 |
|
| 1272 |
|
| 1273 |
|
| 1274 |
|
| 1275 |
|
| 1276 |
|
| 1277 |
private static boolean isCoreSyntaxTerm(int term) |
| 1278 |
{ |
| 1279 |
return RDFTERM_FIRST_CORE <= term && term <= RDFTERM_LAST_CORE; |
| 1280 |
} |
| 1281 |
|
| 1282 |
|
| 1283 |
|
| 1284 |
|
| 1285 |
|
| 1286 |
|
| 1287 |
|
| 1288 |
|
| 1289 |
|
| 1290 |
private static int getRDFTermKind(Node node) |
| 1291 |
{ |
| 1292 |
String localName = node.getLocalName(); |
| 1293 |
String namespace = node.getNamespaceURI(); |
| 1294 |
|
| 1295 |
if ( |
| 1296 |
namespace == null && |
| 1297 |
("about".equals(localName) || "ID".equals(localName)) && |
| 1298 |
(node instanceof Attr) && |
| 1299 |
NS_RDF.equals(((Attr) node).getOwnerElement().getNamespaceURI()) |
| 1300 |
) |
| 1301 |
{ |
| 1302 |
namespace = NS_RDF; |
| 1303 |
} |
| 1304 |
|
| 1305 |
if (NS_RDF.equals(namespace)) |
| 1306 |
{ |
| 1307 |
if ("li".equals(localName)) |
| 1308 |
{ |
| 1309 |
return RDFTERM_LI; |
| 1310 |
} |
| 1311 |
else if ("parseType".equals(localName)) |
| 1312 |
{ |
| 1313 |
return RDFTERM_PARSE_TYPE; |
| 1314 |
} |
| 1315 |
else if ("Description".equals(localName)) |
| 1316 |
{ |
| 1317 |
return RDFTERM_DESCRIPTION; |
| 1318 |
} |
| 1319 |
else if ("about".equals(localName)) |
| 1320 |
{ |
| 1321 |
return RDFTERM_ABOUT; |
| 1322 |
} |
| 1323 |
else if ("resource".equals(localName)) |
| 1324 |
{ |
| 1325 |
return RDFTERM_RESOURCE; |
| 1326 |
} |
| 1327 |
else if ("RDF".equals(localName)) |
| 1328 |
{ |
| 1329 |
return RDFTERM_RDF; |
| 1330 |
} |
| 1331 |
else if ("ID".equals(localName)) |
| 1332 |
{ |
| 1333 |
return RDFTERM_ID; |
| 1334 |
} |
| 1335 |
else if ("nodeID".equals(localName)) |
| 1336 |
{ |
| 1337 |
return RDFTERM_NODE_ID; |
| 1338 |
} |
| 1339 |
else if ("datatype".equals(localName)) |
| 1340 |
{ |
| 1341 |
return RDFTERM_DATATYPE; |
| 1342 |
} |
| 1343 |
else if ("aboutEach".equals(localName)) |
| 1344 |
{ |
| 1345 |
return RDFTERM_ABOUT_EACH; |
| 1346 |
} |
| 1347 |
else if ("aboutEachPrefix".equals(localName)) |
| 1348 |
{ |
| 1349 |
return RDFTERM_ABOUT_EACH_PREFIX; |
| 1350 |
} |
| 1351 |
else if ("bagID".equals(localName)) |
| 1352 |
{ |
| 1353 |
return RDFTERM_BAG_ID; |
| 1354 |
} |
| 1355 |
} |
| 1356 |
|
| 1357 |
return RDFTERM_OTHER; |
| 1358 |
} |
| 1359 |
|
| 1360 |
|
| 1361 |
|
| 1362 |
|
| 1363 |
|
| 1364 |
|
| 1365 |
|
| 1366 |
|
| 1367 |
private static boolean isNumberedArrayItemName(String nodeName) |
| 1368 |
{ |
| 1369 |
boolean result = "rdf:li".equals(nodeName); |
| 1370 |
|
| 1371 |
if (nodeName.startsWith("rdf:_")) |
| 1372 |
{ |
| 1373 |
result = true; |
| 1374 |
for (int i = 5; i < nodeName.length(); i++) |
| 1375 |
{ |
| 1376 |
result = result && nodeName.charAt(i) >= '0' && nodeName.charAt(i) <= '9'; |
| 1377 |
} |
| 1378 |
} |
| 1379 |
|
| 1380 |
return result; |
| 1381 |
} |
| 1382 |
} |