public XPath( String xpath, NamespaceBindings nsContext ) { this.xpath = xpath; this.nsContext = nsContext == null ? new NamespaceBindings() : nsContext; }
/** * Constructs a {@link NamespaceContext} from all active namespace bindings available in the scope of the given * {@link OMElement}. * * @param element * the given element * @return the constructed namespace context */ public NamespaceBindings getNamespaceContext( OMElement element ) { NamespaceBindings nsContext = new NamespaceBindings(); augmentNamespaceContext( element, nsContext ); return nsContext; }
private static ValueReference parsePropertyName( XMLStreamReader xmlStream ) throws XMLStreamException { String propName = xmlStream.getElementText().trim(); if ( propName.isEmpty() ) { // TODO filter encoding guy: use whatever exception shall be used here. But make sure that the // GetObservation100XMLAdapter gets an exception from here as the compliance of the SOS hangs on it's thread throw new XMLParsingException( xmlStream, Messages.getMessage( "FILTER_PARSER_PROPERTY_NAME_EMPTY", new QName( OGC_NS, "PropertyName" ) ) ); } Set<String> prefixes = XPathUtils.extractPrefixes( propName ); return new ValueReference( propName, new NamespaceBindings( xmlStream.getNamespaceContext(), prefixes ) ); }
/** * Creates a new {@link ValueReference} instance that selects a property. * * @param name * qualified name of the property, never <code>null</code> */ public ValueReference( QName name ) { NamespaceBindings nsContext = new NamespaceBindings(); if ( name.getNamespaceURI() != null ) { String prefix = ( name.getPrefix() != null && !"".equals( name.getPrefix() ) ) ? name.getPrefix() : "app"; nsContext.addNamespace( prefix, name.getNamespaceURI() ); this.text = prefix + ":" + name.getLocalPart(); } else { this.text = name.getLocalPart(); } init( nsContext ); }
private static ValueReference parseValueReference( XMLStreamReader xmlStream, boolean permitEmpty ) throws XMLStreamException { requireStartElement( xmlStream, singleton( new QName( FES_NS, "ValueReference" ) ) ); String xpath = xmlStream.getElementText().trim(); if ( !permitEmpty && xpath.isEmpty() ) { throw new XMLParsingException( xmlStream, Messages.getMessage( "FILTER_PARSER_PROPERTY_NAME_EMPTY", new QName( FES_NS, "ValueReference" ) ) ); } if ( xpath.isEmpty() ) { return null; } Set<String> prefixes = XPathUtils.extractPrefixes( xpath ); return new ValueReference( xpath, new NamespaceBindings( xmlStream.getNamespaceContext(), prefixes ) ); }
private static ValueReference parsePropertyName( XMLStreamReader xmlStream, boolean permitEmpty ) throws XMLStreamException { requireStartElement( xmlStream, Collections.singleton( new QName( OGC_NS, "PropertyName" ) ) ); String xpath = xmlStream.getElementText().trim(); if ( !permitEmpty && xpath.isEmpty() ) { // TODO filter encoding guy: use whatever exception shall be used here. But make sure that the // GetObservation100XMLAdapter gets an exception from here as the compliance of the SOS hangs on it's thread throw new XMLParsingException( xmlStream, Messages.getMessage( "FILTER_PARSER_PROPERTY_NAME_EMPTY", new QName( OGC_NS, "PropertyName" ) ) ); } if ( xpath.isEmpty() ) { return null; } Set<String> prefixes = XPathUtils.extractPrefixes( xpath ); return new ValueReference( xpath, new NamespaceBindings( xmlStream.getNamespaceContext(), prefixes ) ); }
public CoupledDataInspector( CoupledResourceInspector config ) { this.config = config; nsContext = new NamespaceBindings(); nsContext.addNamespace( "srv", "http://www.isotc211.org/2005/srv" ); nsContext.addNamespace( "gmd", "http://www.isotc211.org/2005/gmd" ); nsContext.addNamespace( "gco", "http://www.isotc211.org/2005/gco" ); }
private NamespaceBindings getNamespaceBindings( final List<PrebindNamespace> prebindNamespaces ) { if ( prebindNamespaces == null ) { return null; } final NamespaceBindings nsBindings = new NamespaceBindings(); for ( final PrebindNamespace prebindNamespace : prebindNamespaces ) { nsBindings.addNamespace( prebindNamespace.getPrefix(), prebindNamespace.getUri() ); } return nsBindings; }
/** * retrieve the capabilities from an xml file * * @param capabilities */ @SuppressWarnings("unchecked") public WPVSClient( XMLAdapter capabilities ) { this.capabilities = capabilities; // add namespaces to namespace context, to be used later with xpath nsContext = new NamespaceBindings(); // get all defined namespaces from getCapabilities in order to define the namespace context Iterator<OMNamespace> nss = this.capabilities.getRootElement().getAllDeclaredNamespaces(); while ( nss.hasNext() ) { OMNamespace omNs = nss.next(); if ( omNs != null ) { nsContext.addNamespace( omNs.getPrefix(), omNs.getNamespaceURI() ); } } }
private QName determineTargetElementXGml( XMLAdapter annotationXML ) { NamespaceBindings nsContext = new NamespaceBindings(); nsContext.addNamespace( "xs", CommonNamespaces.XSNS ); QName refElement = annotationXML.getNodeAsQName( annotationXML.getRootElement(), new XPath( "xs:appinfo[@source='urn:x-gml:targetElement']/text()", nsContext ), null ); if ( refElement != null ) { LOG.trace( "Identified a target element annotation (urn:x-gml style)." ); } return refElement; }
private static SortProperty parseSortProperty( XMLStreamReader reader ) throws XMLStreamException { requireStartElement( reader, singleton( new QName( OGCNS, "SortProperty" ) ) ); nextElement( reader ); requireStartElement( reader, singleton( new QName( OGCNS, "PropertyName" ) ) ); String xpath = reader.getElementText().trim(); Set<String> prefixes = XPathUtils.extractPrefixes( xpath ); NamespaceBindings nsContext = new NamespaceBindings( reader.getNamespaceContext(), prefixes ); ValueReference propName = new ValueReference( xpath, nsContext ); nextElement( reader ); boolean sortAscending = true; if ( reader.isStartElement() ) { requireStartElement( reader, singleton( new QName( OGCNS, "SortOrder" ) ) ); String s = reader.getElementText().trim(); sortAscending = "ASC".equals( s ); nextElement( reader ); } reader.require( END_ELEMENT, OGCNS, "SortProperty" ); return new SortProperty( propName, sortAscending ); }
private QName determineTargetElementAdv( XMLAdapter annotationXML ) { NamespaceBindings nsContext = new NamespaceBindings(); nsContext.addNamespace( "xs", CommonNamespaces.XSNS ); nsContext.addNamespace( "adv", "http://www.adv-online.de/nas" ); QName refElement = annotationXML.getNodeAsQName( annotationXML.getRootElement(), new XPath( "xs:appinfo/adv:referenziertesElement/text()", nsContext ), null ); if ( refElement != null ) { LOG.trace( "Identified a target element annotation (adv style)." ); } return refElement; }
private QName determineTargetElementGml32( XMLAdapter annotationXML ) { NamespaceBindings nsContext = new NamespaceBindings(); nsContext.addNamespace( "xs", CommonNamespaces.XSNS ); nsContext.addNamespace( "gml", GML3_2_NS ); QName refElement = annotationXML.getNodeAsQName( annotationXML.getRootElement(), new XPath( "xs:appinfo/gml:targetElement/text()", nsContext ), null ); if ( refElement != null ) { LOG.trace( "Identified a target element annotation (GML 3.2 style)." ); } return refElement; }
private String getExternalRef( Feature building ) { String result = null; NamespaceBindings nsContext = new NamespaceBindings(); nsContext.addNamespace( "cgml", NS ); ValueReference propName = new ValueReference( "cgml:externalReference/cgml:informationSystem/text()", nsContext ); TypedObjectNodeXPathEvaluator evaluator = new TypedObjectNodeXPathEvaluator( ); TypedObjectNode[] tons; try { tons = evaluator.eval( building, propName ); if ( tons.length > 0 ) { result = ( (PrimitiveValue) tons[0] ).getAsText().trim(); } } catch ( FilterEvaluationException e ) { LOG.error( "Retrieving of information system property failed: " + e.getMessage() ); } return result; }
private FeaturePropertyType buildFeaturePropertyTypeXGml( QName ptName, XSElementDeclaration elementDecl, XSComplexTypeDefinition typeDef, int minOccurs, int maxOccurs, List<PropertyType> ptSubstitutions, XMLAdapter annotationXML ) { // handle schemas that use a source="urn:x-gml:targetElement" attribute // for defining the referenced feature type // inside the annotation element (e.g. CITE examples for WFS 1.1.0) NamespaceBindings nsContext = new NamespaceBindings(); nsContext.addNamespace( "xs", CommonNamespaces.XSNS ); QName refElement = annotationXML.getNodeAsQName( annotationXML.getRootElement(), new XPath( "xs:appinfo[@source='urn:x-gml:targetElement']/text()", nsContext ), null ); if ( refElement != null ) { LOG.debug( "Identified a feature property (urn:x-gml:targetElement)." ); FeaturePropertyType pt = new FeaturePropertyType( ptName, minOccurs, maxOccurs, elementDecl, ptSubstitutions, refElement, ValueRepresentation.BOTH ); return pt; } return null; }
private FeaturePropertyType buildFeaturePropertyTypeAdv( QName ptName, XSElementDeclaration elementDecl, XSComplexTypeDefinition typeDef, int minOccurs, int maxOccurs, List<PropertyType> ptSubstitutions, XMLAdapter annotationXML ) { // handle adv schemas (referenced feature type inside annotation // element) NamespaceBindings nsContext = new NamespaceBindings(); nsContext.addNamespace( "xs", CommonNamespaces.XSNS ); nsContext.addNamespace( "adv", "http://www.adv-online.de/nas" ); QName refElement = annotationXML.getNodeAsQName( annotationXML.getRootElement(), new XPath( "xs:appinfo/adv:referenziertesElement/text()", nsContext ), null ); if ( refElement != null ) { LOG.trace( "Identified a feature property (adv style)." ); FeaturePropertyType pt = new FeaturePropertyType( ptName, minOccurs, maxOccurs, elementDecl, ptSubstitutions, refElement, ValueRepresentation.BOTH ); return pt; } return null; }
private FeaturePropertyType buildFeaturePropertyTypeGML32( QName ptName, XSElementDeclaration elementDecl, XSComplexTypeDefinition typeDef, int minOccurs, int maxOccurs, List<PropertyType> ptSubstitutions, XMLAdapter annotationXML ) { // handle GML 3.2 schemas (referenced feature type inside annotation element) NamespaceBindings nsContext = new NamespaceBindings(); nsContext.addNamespace( "xs", CommonNamespaces.XSNS ); nsContext.addNamespace( "gml", GML3_2_NS ); QName refElement = annotationXML.getNodeAsQName( annotationXML.getRootElement(), new XPath( "xs:appinfo/gml:targetElement/text()", nsContext ), null ); if ( refElement != null ) { LOG.trace( "Identified a feature property (GML 3.2 style)." ); // TODO determine this properly ValueRepresentation vp = ValueRepresentation.REMOTE; FeaturePropertyType pt = new FeaturePropertyType( ptName, minOccurs, maxOccurs, elementDecl, ptSubstitutions, refElement, vp ); return pt; } return null; }
private String getCodeListId( final XSElementDeclaration elementDecl ) { String codeListId = null; // handle adv schemas (referenced code list id inside annotation element) XSObjectList annotations = elementDecl.getAnnotations(); if ( annotations.getLength() > 0 ) { XSAnnotation annotation = (XSAnnotation) annotations.item( 0 ); String s = annotation.getAnnotationString(); XMLAdapter adapter = new XMLAdapter( new StringReader( s ) ); NamespaceBindings nsContext = new NamespaceBindings(); nsContext.addNamespace( "xs", CommonNamespaces.XSNS ); nsContext.addNamespace( "adv", "http://www.adv-online.de/nas" ); codeListId = adapter.getNodeAsString( adapter.getRootElement(), new XPath( "xs:appinfo/adv:referenzierteCodeList/text()", nsContext ), null ); if ( codeListId != null ) { codeListId = codeListId.trim(); } } return codeListId; }
@Override public void init( DeegreeServicesMetadataType serviceMetadata, DeegreeServiceControllerType mainConf, Object controllerConf ) { LOG.info( "Checking for JOGL." ); JOGLChecker.check(); LOG.info( "JOGL status check successful." ); identification = serviceMetadata.getServiceIdentification(); provider = serviceMetadata.getServiceProvider(); DeegreeWPVS cfg = (DeegreeWPVS) controllerConf; NamespaceBindings nsContext = new NamespaceBindings(); nsContext.addNamespace( "wpvs", "http://www.deegree.org/services/wpvs" ); try { publishedInformation = cfg.getPublishedInformation(); parsePublishedInformation( nsContext, publishedInformation ); ServiceConfiguration sc = cfg.getServiceConfiguration(); service = new PerspectiveViewService( metadata.getLocation(), sc, workspace ); } catch ( ServiceInitException e ) { throw new ResourceInitException( e.getMessage(), e ); } }
@Override public void init( DeegreeServicesMetadataType serviceMetadata, DeegreeServiceControllerType mainConf, Object controllerConf ) { LOG.info( "Initializing WCS." ); UPDATE_SEQUENCE++; DeegreeWCS cfg = (DeegreeWCS) controllerConf; NamespaceBindings nsContext = new NamespaceBindings(); nsContext.addNamespace( WCSConstants.WCS_100_PRE, WCS_100_NS ); nsContext.addNamespace( WCSConstants.WCS_110_PRE, WCSConstants.WCS_110_NS ); nsContext.addNamespace( CONFIG_PRE, CONFIG_NS ); this.wcsService = new WCServiceBuilder( workspace, getMetadata() ).buildService(); PublishedInformation publishedInformation = cfg.getPublishedInformation(); parsePublishedInformation( publishedInformation, nsContext ); syncWithMainController( publishedInformation, serviceMetadata ); validateAndSetOfferedVersions( publishedInformation.getSupportedVersions().getVersion() ); mainControllerConf = mainConf; mainMetadataConf = serviceMetadata; }