[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
[Recent Entries]
[Reply To This Message]
Re: Correcting unbound namespace prefixes
I forgot to mention that make_parser() comes from importing
"xml.sax", and "handler" is an instance of a class derived from
importing "xml.sax.handler" that intercepts the start of element
event while recreating the output, injecting your required namespace
declarations.
But, really, I should have told you this on XML Dev.
. . . . . . . . . Ken
At 2010-08-02 12:22 -0400, I wrote:
At 2010-08-02 09:08 -0700, Tony Nassar wrote:
I'm not sure this is the correct place to post.
It isn't, because it isn't related to XSLT or XSL-FO. I'm not the
moderator, but the moderator is very busy this week running the
Balisage conference with her colleagues.
Post your to the OASIS XML-Dev list where people can help you
regarding such questions.
Personally, since you mention Python and I am a fan of Python, I
would try to run this as follows (though I haven't tested it):
parser = make_parser()
parser.setFeature( "http://xml.org/sax/features/namespaces", False )
parser.setContentHandler( handler )
parser.parse( fileIn )
.... where "handler" find elements that have a prefix and makes
assumptions about the namespaces required for those prefixes.
I hope this helps.
. . . . . . . . . . . Ken
This may be a question about JAXP, or simply about good standard
operating procedure for bad input data.
I've got some XML that I know is invalid, but I'm not in a position
to get the customer to fix it. Here's what it looks like:
<document>
<text>Four score and twenty years ago..,</text>
<pp:metadata publication-date="2010-07-31T12:30:00Z" />
...
You get the idea (I hope): clearly someone began with XML in the ""
namespace, extracted metadata in a post-processing step, and
inserted the corresponding markup without adding the necessary
namespace declarations or mapping "pp" to one. I don't know of a
way to fix this through the JAXP API (i.e. interpolating the prefix
mapping). Or am I better off just preprocessing this XML via Perl
or Python before it's ever parsed?
Tony Nassar Ph.D.
Palantir Technologies | Forward Deployed Engineer
--
XSLT/XQuery training: after http://XMLPrague.cz 2011-03-28/04-01
Vote for your XML training: http://www.CraneSoftwrights.com/s/i/
Crane Softwrights Ltd. http://www.CraneSoftwrights.com/s/
G. Ken Holman mailto:gkholman@xxxxxxxxxxxxxxxxxxxx
Male Cancer Awareness Nov'07 http://www.CraneSoftwrights.com/s/bc
Legal business disclaimers: http://www.CraneSoftwrights.com/legal
|
PURCHASE STYLUS STUDIO ONLINE TODAY!
Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!
Download The World's Best XML IDE!
Accelerate XML development with our award-winning XML IDE - Download a free trial today!
Subscribe in XML format
RSS 2.0 |
|
Atom 0.3 |
|
|