From: Patrick B. <pat...@jo...> - 2011-08-18 13:00:14
|
Hi guys, Thanks for the responses. Adam, you're right, I can just pass along a new AttrList. I had tried this method before and wasn't getting what I expected. Turns out some of my other logic was preventing the proper output, and I mistook it for the AttrList not propagating properly. Cheers, Patrick On Wed, Aug 17, 2011 at 6:54 PM, Adam Retter <ad...@ex...> wrote: > Dan that wont crack it im afraid, as you can only modify a document > stream before storage using a Java Trigger, such things are not 'yet' > possible from an XQuery Trigger... > > On 18 August 2011 00:17, Dan McCreary <dan...@gm...> wrote: > > Hi Patrick, > > > > Here is one approach: > > > > > http://en.wikibooks.org/wiki/XQuery/Filtering_Nodes#Removing_named_attributes > > > > It filters a document which can then be serialized. > > > > - Dan > > > > On Tue, Aug 16, 2011 at 7:24 PM, Patrick Bosek <pat...@jo... > > > > wrote: > >> > >> Hi Everyone, > >> > >> I'm trying to write a custom filter to remove attributes as a document > is > >> serialized. It seems pretty easy to add attributes, but I can't seem to > find > >> any way to remove them. Any suggestions? > >> > >> > >> > >> public void startElement(QName qname, AttrList attribs) throws > >> SAXException { > >> if (elementStack == 0) { > >> StoredNode node = getCurrentNode(); > >> if (node != null) { > >> DocumentImpl doc = node.getDocument(); > >> XmldbURI uri = doc.getURI(); > >> if (!uri.startsWith(XmldbURI.SYSTEM_COLLECTION_URI)) { > >> if > (doc.getCollection().getConfiguration(getBroker()). > >> triggerRegistered(VersioningTrigger.class)) > { > >> try { > >> long rev = > >> VersioningHelper.getCurrentRevision(getBroker(), doc.getURI()); > >> long time = System.currentTimeMillis(); > >> String key = Long.toHexString(time) + > >> Long.toHexString(rev); > >> > >> > >> --- Attributes being added ------| > >> > >> > >> V > >> > >> attribs.addAttribute(ATTR_REVISION, rev == 0 > ? > >> "0" : Long.toString(rev)); > >> attribs.addAttribute(ATTR_KEY, key); > >> attribs.addAttribute(ATTR_PATH, > >> doc.getURI().toString()); > >> } catch (XPathException e) { > >> LOG.error("Exception while retrieving > >> versioning info: " + e.getMessage(), e); > >> } catch (IOException e) { > >> LOG.error("Exception while retrieving > >> versioning info: " + e.getMessage(), e); > >> } > >> } > >> } > >> } > >> } > >> ++elementStack; > >> nextListener.startElement(qname, attribs); > >> } > >> > >> > >> -- > >> Patrick Bosek > >> Jorsek Software > >> Cell (585) 820 9634 > >> Office (877) 492 2960 > >> Jorsek.com > >> > >> > >> > >> > ------------------------------------------------------------------------------ > >> Get a FREE DOWNLOAD! and learn more about uberSVN rich system, > >> user administration capabilities and model configuration. Take > >> the hassle out of deploying and managing Subversion and the > >> tools developers use with it. http://p.sf.net/sfu/wandisco-d2d-2 > >> _______________________________________________ > >> Exist-open mailing list > >> Exi...@li... > >> https://lists.sourceforge.net/lists/listinfo/exist-open > >> > > > > > > > > -- > > Dan McCreary > > Semantic Solutions Architect > > office: (952) 931-9198 > > cell: (612) 986-1552 > > > > > ------------------------------------------------------------------------------ > > Get a FREE DOWNLOAD! and learn more about uberSVN rich system, > > user administration capabilities and model configuration. Take > > the hassle out of deploying and managing Subversion and the > > tools developers use with it. http://p.sf.net/sfu/wandisco-d2d-2 > > _______________________________________________ > > Exist-open mailing list > > Exi...@li... > > https://lists.sourceforge.net/lists/listinfo/exist-open > > > > > > > > -- > Adam Retter > > eXist Developer > { United Kingdom } > ad...@ex... > irc://irc.freenode.net/existdb > -- Patrick Bosek Jorsek Software Cell (585) 820 9634 Office (877) 492 2960 Jorsek.com |