Exemplo n.º 1
0
        /// <summary>
        /// Get a list of external variables used by the expression. This will include both variables that were explicitly
        /// declared to the <c>XPathCompiler</c>, and (if the <c>AllowUndeclaredVariables</c> option was set) variables that
        /// are referenced within the expression but not explicitly declared.
        /// </summary>
        /// <returns>
        /// An IEnumerator over the names of the external variables, as instances of <c>QName</c>.</returns>

        public IEnumerator EnumerateExternalVariables()
        {
            ArrayList list = new ArrayList();
            JIterator iter = env.iterateExternalVariables();

            while (iter.hasNext())
            {
                JXPathVariable   var = (JXPathVariable)iter.next();
                JStructuredQName q   = var.getVariableQName();
                list.Add(new QName(q.getPrefix(), q.getURI(), q.getLocalPart()));
            }
            return(list.GetEnumerator());
        }
Exemplo n.º 2
0
        internal JReceiver GetReceiver(Serializer serializer)
        {
            net.sf.saxon.expr.instruct.Executable executable = exp.getExecutable();
            JConfiguration         config = executable.getConfiguration();
            JPipelineConfiguration pipe   = config.makePipelineConfiguration();

            pipe.setHostLanguage(executable.getHostLanguage());
            JProperties baseProps = new JProperties(executable.getDefaultOutputProperties());

            JCharacterMapIndex charMapIndex = executable.getCharacterMapIndex();
            JCharacterMapIndex characterMap = serializer.GetCharacterMap();

            if (charMapIndex.isEmpty())
            {
                charMapIndex = characterMap;
            }
            else if (characterMap != null && !characterMap.isEmpty() && charMapIndex != characterMap)
            {
                // Merge the character maps
                java.util.Iterator mapIter = characterMap.iterator();
                while (mapIter.hasNext())
                {
                    net.sf.saxon.serialize.CharacterMap map = (net.sf.saxon.serialize.CharacterMap)mapIter.next();
                    charMapIndex.putCharacterMap(map.getName(), map);
                }
            }

            JProperties properties = serializer.GetOutputProperties();

            object [] propSet = properties.entrySet().toArray();

            for (int i = 0; i < properties.size(); i++)
            {
                java.util.Map.Entry             entry = (java.util.Map.Entry)propSet[i];
                net.sf.saxon.om.StructuredQName name  = net.sf.saxon.om.StructuredQName.fromClarkName((String)entry.getKey());
                net.sf.saxon.expr.instruct.ResultDocument.setSerializationProperty(
                    baseProps, name.getURI(), name.getLocalPart(), (String)entry.getValue(), null, true, config);
            }
            serializer.SetDefaultOutputProperties(baseProps);
            serializer.SetCharacterMap(charMapIndex);

            JReceiver target = serializer.GetReceiver(pipe);

            return(target);
        }