Beispiel #1
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);
        }