Package org.graphity.client.util

Examples of org.graphity.client.util.XSLTBuilder


        }
    }
   
    public XSLTBuilder getXSLTBuilder(InputStream is, MultivaluedMap<String, Object> headerMap, OutputStream os) throws TransformerConfigurationException
    {
        XSLTBuilder bld = getXSLTBuilder().
      document(is).
      parameter("{" + GP.baseUri.getNameSpace() + "}" + GP.baseUri.getLocalName(), getUriInfo().getBaseUri()).
      parameter("{" + GP.absolutePath.getNameSpace() + "}" + GP.absolutePath.getLocalName(), getUriInfo().getAbsolutePath()).
      parameter("{" + GP.requestUri.getNameSpace() + "}" + GP.requestUri.getLocalName(), getUriInfo().getRequestUri()).
      parameter("{" + GP.httpHeaders.getNameSpace() + "}" + GP.httpHeaders.getLocalName(), headerMap.toString()).
      result(new StreamResult(os));

  // injecting Resource to get the final state of its Model. Is there a better way to do this?
        if (!getUriInfo().getMatchedResources().isEmpty())
        {
            Resource resource = (Resource)getUriInfo().getMatchedResources().get(0);
            if (log.isDebugEnabled()) log.debug("Matched Resource: {}", resource);
            MatchedIndividual match = (MatchedIndividual)resource;

      bld.parameter("{" + GP.matchedOntClass.getNameSpace() + "}" + GP.matchedOntClass.getLocalName(), URI.create(match.getMatchedOntClass().getURI())).
            parameter("{" + GP.ontModel.getNameSpace() + "}" + GP.ontModel.getLocalName(), getSource(match.getOntModel(), true)); // $ont-model from the current Resource (with imports)
        }
       
  Object contentType = headerMap.getFirst(HttpHeaders.CONTENT_TYPE);
  if (contentType != null)
  {
      if (log.isDebugEnabled()) log.debug("Writing Model using XSLT media type: {}", contentType);
      bld.outputProperty(OutputKeys.MEDIA_TYPE, contentType.toString());
  }
  Object contentLanguage = headerMap.getFirst(HttpHeaders.CONTENT_LANGUAGE);
  if (contentLanguage != null)
  {
      if (log.isDebugEnabled()) log.debug("Writing Model using language: {}", contentLanguage.toString());
      bld.parameter("{" + GC.lang.getNameSpace() + "}" + GC.lang.getLocalName(), contentLanguage.toString());
  }

        // pass HTTP query parameters into XSLT, ignore reserved param names (as params cannot be unset)
  Iterator<Entry<String, List<String>>> it = getUriInfo().getQueryParameters().entrySet().iterator();
        while (it.hasNext())
        {
            Entry<String, List<String>> entry = it.next();
            if (!getReservedParameterNames().contains(entry.getKey()))
            {
                bld.parameter(entry.getKey(), entry.getValue().get(0)); // set string value
                if (log.isDebugEnabled()) log.debug("Setting XSLT param \"{}\" from HTTP query string with value: {}", entry.getKey(), entry.getValue().get(0));
            }
            else
                if (log.isDebugEnabled()) log.debug("HTTP query string param \"{}\" is reserved in XSLT writer, ignoring", entry.getKey());
        }

        // override the reserved parameters that need special types
  if (getUriInfo().getQueryParameters().getFirst(GC.mode.getLocalName()) != null)
      bld.parameter("{" + GC.mode.getNameSpace() + "}" + GC.mode.getLocalName(),
                    URI.create(getUriInfo().getQueryParameters().getFirst(GC.mode.getLocalName())));
  if (getUriInfo().getQueryParameters().getFirst(GC.uri.getLocalName()) != null)
      bld.parameter("{" + GC.uri.getNameSpace() + "}" + GC.uri.getLocalName(),
                URI.create(getUriInfo().getQueryParameters().getFirst(GC.uri.getLocalName())));
  if (getUriInfo().getQueryParameters().getFirst(GC.endpointUri.getLocalName()) != null)
      bld.parameter("{" + GC.endpointUri.getNameSpace() + "}" + GC.endpointUri.getLocalName(),
                    URI.create(getUriInfo().getQueryParameters().getFirst(GC.endpointUri.getLocalName())));

  return bld;
    }
View Full Code Here

TOP

Related Classes of org.graphity.client.util.XSLTBuilder

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.