addQueryToNode(xpath, ((NameStep) step2).getLocalName()); valid = true;
private QName getQName( NameStep step ) { String prefix = step.getPrefix(); QName qName; if ( prefix.isEmpty() ) { qName = new QName( step.getLocalName() ); } else { String ns = nsBindings.translateNamespacePrefixToUri( prefix ); qName = new QName( ns, step.getLocalName(), prefix ); } return qName; }
if ( lpath.getSteps().get( 0 ) instanceof NameStep ) { NameStep step = (NameStep) lpath.getSteps().get( 0 ); if ( step.getAxis() == Axis.CHILD && step.getPredicates().isEmpty() && !step.getLocalName().equals( "*" ) ) { String prefix = step.getPrefix(); if ( prefix.isEmpty() ) { qName = new QName( step.getLocalName() ); } else { String ns = this.bindings.translateNamespacePrefixToUri( prefix ); qName = new QName( ns, step.getLocalName(), prefix );
private boolean isChildElementStepWithoutPredicateOrWithNumberPredicate( NameStep step ) { if ( step.getAxis() == CHILD && !step.getLocalName().equals( "*" ) ) { if ( step.getPredicates().isEmpty() ) { return true; } else if ( step.getPredicates().size() == 1 ) { Predicate predicate = (Predicate) step.getPredicates().get( 0 ); Expr expr = predicate.getExpr(); if ( expr instanceof NumberExpr ) { return true; } } } return false; } }
private boolean isElementStep( NameStep step, QName elName ) { if ( step.getAxis() != CHILD ) { return false; } // TODO namespace awareness return elName.getLocalPart().equals( step.getLocalName() ); }
private Pair<QName, Integer> trySimpleMultiProp( ValueReference valueReference, FeatureType ft ) throws OWSException { Expr expr = valueReference.getAsXPath(); if ( !( expr instanceof LocationPath ) ) { throw new OWSException( "Cannot update property on feature type '" + ft.getName() + "'. Complex property paths are not supported.", OPERATION_NOT_SUPPORTED ); } Object obj = ( (LocationPath) expr ).getSteps().get( 0 ); if ( !( obj instanceof NameStep ) ) { throw new OWSException( "Cannot update property on feature type '" + ft.getName() + "'. Complex property paths are not supported.", OPERATION_NOT_SUPPORTED ); } NameStep namestep = (NameStep) obj; obj = namestep.getPredicates().get( 0 ); if ( !( obj instanceof Predicate ) ) { throw new OWSException( "Cannot update property on feature type '" + ft.getName() + "'. Complex property paths are not supported.", OPERATION_NOT_SUPPORTED ); } Predicate pred = (Predicate) obj; expr = pred.getExpr(); if ( !( expr instanceof NumberExpr ) ) { throw new OWSException( "Cannot update property on feature type '" + ft.getName() + "'. Complex property paths are not supported.", OPERATION_NOT_SUPPORTED ); } NumberExpr ne = (NumberExpr) expr; int index = Math.round( Float.parseFloat( ne.getText() ) ); String namespaceUri = determineNamespaceUri( valueReference, ft, namestep ); return new Pair<QName, Integer>( new QName( namespaceUri, namestep.getLocalName() ), index - 1 ); }
private static void extractPrefixes( Step step, Set<String> prefixes ) { if ( step instanceof NameStep ) { extractPrefix( ( (NameStep) step ).getPrefix(), prefixes ); } }
private int getNumber( NameStep step ) { int num = 0; if ( !step.getPredicates().isEmpty() ) { List<?> predicates = step.getPredicates(); if ( predicates.size() == 1 ) { Expr predicate = ( (Predicate) predicates.get( 0 ) ).getExpr(); if ( predicate instanceof NumberExpr ) { num = ( (NumberExpr) predicate ).getNumber().intValue(); } } } return num; }
if ( o instanceof NameStep ) { NameStep step = (NameStep) o; if ( step.getAxis() == Axis.CHILD ) {
private QName getQName( NameStep step ) { String prefix = step.getPrefix(); QName qName; if ( prefix.isEmpty() ) { qName = new QName( step.getLocalName() ); } else { String ns = nsBindings.translateNamespacePrefixToUri( prefix ); qName = new QName( ns, step.getLocalName(), prefix ); } return qName; }
} else { NameStep namestep = (NameStep) step; String prefix = namestep.getPrefix(); String localPart = namestep.getLocalName(); String namespace = propName.getNsContext().translateNamespacePrefixToUri( prefix ); QName nodeName = new QName( namespace, localPart, prefix ); if ( namestep.getAxis() == Axis.ATTRIBUTE ) { if ( namestep.getPredicates() != null && !namestep.getPredicates().isEmpty() ) { String msg = "Unable to map PropertyName '" + propName.getAsText() + "': contains an attribute NameStep with a predicate."; } else if ( namestep.getAxis() == Axis.CHILD ) { if ( namestep.getPredicates() != null && !namestep.getPredicates().isEmpty() ) { String msg = "Unable to map PropertyName '" + propName.getAsText() + "': contains an element NameStep with a predicate (needs implementation).";
private SlotMapping getSlot( ValueReference propName, NameStep slotStep ) throws UnmappableException { List<?> predicates = slotStep.getPredicates(); if ( predicates == null || predicates.isEmpty() ) { String msg = "Unable to map PropertyName '" + propName.getAsText() if ( !( lhs instanceof LocationPath ) || ( (LocationPath) lhs ).getSteps().size() != 1 || !( ( (LocationPath) lhs ).getSteps().get( 0 ) instanceof NameStep ) || ( (NameStep) ( (LocationPath) lhs ).getSteps().get( 0 ) ).getAxis() != ATTRIBUTE || !( (NameStep) ( (LocationPath) lhs ).getSteps().get( 0 ) ).getLocalName().equals( "name" ) ) { String msg = "Unable to map PropertyName '" + propName.getAsText() + "'. Slot steps must specify a single name predicate (../rim:Slot[@name=...]).";
private boolean isAttrStep( NameStep step, QName attrName ) { if ( step.getAxis() != ATTRIBUTE ) { return false; } // TODO namespace awareness return attrName.getLocalPart().equals( step.getLocalName() ); }
private String determineNamespaceUri( ValueReference valueReference, FeatureType ft, NameStep namestep ) { String prefix = namestep.getPrefix(); if ( prefix != null && !"".equals( prefix ) ) { String namespaceUriByPrefix = valueReference.getNsContext().getNamespaceURI( prefix ); if ( namespaceUriByPrefix != null && !"".equals( namespaceUriByPrefix ) ) return namespaceUriByPrefix; } return ft.getName().getNamespaceURI(); }
private static void findQName( List<QName> list, Step step, NamespaceBindings nsContext ) { if ( step instanceof NameStep ) { NameStep ns = (NameStep) step; list.add( new QName( nsContext.getNamespaceURI( ns.getPrefix() ), ns.getLocalName() ) ); } }
if ( step.getAxis() != ATTRIBUTE && step.getAxis() != CHILD ) { String msg = "Unable to map PropertyName '" + propName.getAsText() + "': step " + stepNo + " (" + o + ") is not a step on the child or attribute axis."; if ( expr instanceof LocationPath ) { NameStep firstStep = (NameStep) steps.get( 0 ); if ( "*".equals( firstStep.getLocalName() ) ) { String msg = "Unable to map PropertyName '" + propName.getAsText() + "'. First step must not be '*'."; throw new UnmappableException( msg ); if ( !firstStep.getPredicates().isEmpty() ) { String msg = "Unable to map PropertyName '" + propName.getAsText() + "'. Predicates are not allowed for first step (" + firstStep + ")."; throw new UnmappableException( msg ); type = aliasToType.get( firstStep.getLocalName() ); } else { Expr filterExpr = ( (PathExpr) expr ).getFilterExpr();
if ( next.getAxis() != CHILD ) { String msg = "Invalid property name expression '" + propName + "'. Cannot target RegistryObjectList attributes."; throw new UnmappableException( msg ); String childTypeName = next.getLocalName(); RIMType childType = RIMType.valueOf( childTypeName ); switch ( childType ) {
addQueryToNode(xpath, ((NameStep) step2).getLocalName()); valid = true;
private QName toQName(Step step, PredicatesEvaluatorBuilder evaluatorCompiler) throws SAXPathException { String nsPrefix = ((NameStep) step).getPrefix(); String localPart = ((NameStep) step).getLocalName(); if(nsPrefix != null && !nsPrefix.trim().equals("")) { if(evaluatorCompiler != null) { return new QName(evaluatorCompiler.getNamespace(nsPrefix), localPart, nsPrefix); } else { // Will need to update the namespace later... when we have the // namespace prefix-to-uri mappings... return new QName(null, localPart, nsPrefix); } } else { return new QName(localPart); } }