XMLNode.XMLNode. The XMLNode.hasBoundPrefixes() will only return true if there are prefixes. XMLNode. The XMLNode.hasBoundURIs() will only return true if there are URIs. <root xsi:schemaLocation="http://my/schema.xsd xmlnode.xsd" xmlns="http://my/schema.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <child name="first"> <child1 name2="second"/> <child1 name2="third"/> </child> </root>If we parse the file with the XMLNodeUtilitiesOptions.NAMESPACE_AWARE option:
XMLRoot root = XMLNodeUtilities.getRootNode(<the XML file>, XMLNodeUtilitiesOptions.NAMESPACE_AWARE);Then we will have:
root.getBoundPrefix("http://www.w3.org/2001/XMLSchema-instance") is "xsi"root.getBoundPrefix("http://my/schema.xsd") is ""root.getBoundURI("xsi") is "http://www.w3.org/2001/XMLSchema-instance"root.getBoundURI("") is "http://my/schema.xsd"http://www.w3.org/2001/XMLSchema-instance URI. For example in the previous example it will return "xsi".XMLSchemaLocation has methgods to:<a661_df xmlns="http://mySchema.com/a661" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ext="http://myExtendedSchema.com/a661" xsi:schemaLocation="http://mySchema.com/a661 a661.xsd http://myExtendedSchema.com/a661 a661Extension.xsd" name="Layer" library_version="0" supp_version="7"> </a661_df>The following code will get the nodes structure:
XMLRoot root = XMLNodeUtilities.getRootNode(<the XML file>, XMLNodeUtilities.NAMESPACE_AWARE);To get the schema locations:
Map<String, XMLSchemaLocation> locations = root.getSchemaLocations(); XMLSchemaLocation location = locations.get("http://mySchema.com/a661"); // location.getURI() is "http://mySchema.com/a661" // location.getPrefix() is "" // location.getLocation() is "a661.xsd" location = locations.get("http://myExtendedSchema.com/a661"); // location.getURI() is "http://myExtendedSchema.com/a661" // location.getPrefix() is "ext" // location.getLocation() is "a661Extension.xsd"
Copyright 2006-2024 Herve Girod. All Rights Reserved. Documentation and source under the LGPL v2 and Apache 2.0 licences