[
https://issues.apache.org/jira/browse/XERCESJ-1086?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Elliotte Rusty Harold closed XERCESJ-1086.
------------------------------------------
> possibility to access namespace-to-prefix bindings from original schema
> -----------------------------------------------------------------------
>
> Key: XERCESJ-1086
> URL: https://issues.apache.org/jira/browse/XERCESJ-1086
> Project: Xerces2-J
> Issue Type: Improvement
> Components: XML Schema API
> Affects Versions: 2.6.2
> Environment: Windows XP, Java 1.4
> Reporter: patins
> Priority: Minor
>
> Hello, I have build a XML editor and my functionality "create new document
> from given schema"
> needs a way to get prefixes for namespaces used in the XML Schema so they
> can be used in the instance conforming to that schema (in contrast to the
> need to
> "randomly" image prefixes). E.g. XHTML including MathML like
> <h1>
> <math:math>
> <math:arccos/>
> </math:math>
> </h1>
> uses the "math" prefix automatically for elements added from the MathML
> schema
> (an example of XHTML using MathML is included in my XDoc program at
> http://xdoc.sourceforge.net/) since this prefix was already used in the
> schema which
> includes mathml into xhtml).
> Currently I use following solution in my editor with modified Xerces source
> files:
> in XSDHandler.java:
> sg.addDocument(currSchemaInfo.fSchemaDoc,
> (String)fDoc2SystemId.get(currSchemaInfo));
> in the original, currSchemaInfo.fSchemaDoc was "nulled":
> sg.addDocument(null, (String)fDoc2SystemId.get(currSchemaInfo.fSchemaDoc));
> with following comment:
> // REVISIT: don't expose the DOM tree
> Anyone knows why?
> Now I modify "addDocument" to collect the prefixes from the DOM tree:
> in SchemaGrammar.java:
> public synchronized void addDocument(Object document, String location) {
> if (fDocuments == null) {
> fDocuments = new Vector();
> fLocations = new Vector();
> }
> fDocuments.addElement(document);
> fLocations.addElement(location);
> /*the rest of the method is new:*/
> Document doc=((Document)document);
> NamedNodeMap attrs=doc.getDocumentElement().getAttributes();
> for (int i=0; i<attrs.getLength(); i++)
> if ("xmlns".equals(attrs.item(i).getPrefix())) {
> Attr attr=(Attr)attrs.item(i);
> CollectPrefixNames.add(attr.getLocalName());
> CollectPrefixValues.add(attr.getValue());
> }
> }
> with following public attributes:
> public Vector CollectPrefixNames=new Vector();
> public Vector CollectPrefixValues=new Vector();
> So i know the ith prefix/namespace pair with CollectPrefixNames.get(i)/
> CollectPrefixValues.get(i).
> By the way its not important to "collect" the DOM instance, I only need to
> get the prefixes.
> If now someone says: "Then please open that XML Schema and collect the
> prefixes on your
> own" I say that this would mean building the DOM tree
> *first for reading in the schema in the validation process and
> *second for just collecting the namespace prefixes.
> So it takes nearly twice computation time.
> Since this is the only lack of functionality I found in Xerces (besides some
> bugs)
> in combination with my XML editor "XDoc" which is very tight bound to Xerces,
> it would be nice if
> the changes of above could be added by someone
--
This message was sent by Atlassian Jira
(v8.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]