I am sure I am working in the right location because if I delete the commented out <render:generic-elem > element then the <p> element is eliminated.
It looks like the <render:generic-elem> element is being evaluated, even when it has been commented out. Betty > Hi Betty, > > No, config.xqy does not need to import that module; and there's no need to > import in the other direction unless you want access to variables from > config.xqy. > > Make sure that you've replaced the right rule; there are several children > of $TRANSFORM (abstract-title, abstract-metadata, item-detail), and if > you're rendering that element in several places, you might have different > rules for it in each place. The first two I mentioned are used to display > result items in a list; the last one is used on the detail page. This > sounds like the most likely problem since it's still rendering a <p> tag. > > --Colleen > > > ________________________________________ > From: [email protected] > [[email protected]] On Behalf Of Betty Harvey > [[email protected]] > Sent: Thursday, July 02, 2009 10:31 AM > To: General Mark Logic Developer Discussion > Subject: [MarkLogic Dev General] Odd Behavior - was Best Approach for > Formatting Content From Application Builder > > Thanks Colleen! > > That is what I want to do. I tried your code and it didn't but I did > notice some interesting behavior. > > I had the following line commented out: > > (: <render:generic-elem match-name="Component" match-ns="" tag="p" > xmlns:render="http://marklogic.com/renderapi"/> :) > > When I look at the output I see: > > <p class="render-Component">Directory Services</p> > > It is still picking up the <render:generic> element even though it is > commented out. > > If I delete that line <render:generic> line then I get no formatting. > > Do I need to import the custom module into the config.xqy file? > > Thanks! > > Betty > > >> Hi Betty, >> >> It looks like you're headed in the right direction, but there are a >> couple >> of things in the function that might be causing problem. >> >> I'm assuming an input context node that looks like this: >> >> <Component>foo</Component> >> >> And desired output that looks like this: >> >> <xhtml:p xmlns:xhtml="http://www.w3.org/1999/xhtml"><xhtml:b>Component: >> </xhtml:b>foo</xhtml:p> >> >> If that's right, then your render element looks good, but I think your >> function should look like: >> >> declare function custom:Component($context as node(), $matchedrule as >> element(), $rules as element()+, >> $params as xs:string*)) as element()+ { >> { >> element xhtml:p { >> element xhtml:b {"Component: "}, $context/string() >> } >> }; >> >> If that's not what you're looking for, please send along what you expect >> that input and output to be, and we'll see if we can get you past the >> problem. >> >> --Colleen Whitney >> >> ________________________________________ >> From: [email protected] >> [[email protected]] On Behalf Of Betty Harvey >> [[email protected]] >> Sent: Thursday, July 02, 2009 8:05 AM >> To: General Mark Logic Developer Discussion >> Subject: Re: [MarkLogic Dev General] Best Approach for Formatting >> Content >> From Application Builder >> >> I think I have followed the instructions but can't get it to work. IE >> doesn't support CSS before and after text. I am also noticing quite a >> few styling differences between Firefox and IE. Unfortunately, I am >> stuck presenting in IE 6. >> >> Here is the code that I have. I have included the <render:generic> >> element >> so you can see the original declaration from the application. I am >> thinking it is a namespace issue. >> >> <!-- My custom.xqy --> >> xquery version '1.0-ml'; >> >> module namespace custom="http://www.eccnet.com"; >> declare namespace xhtml="http://www.w3.org/1999/xhtml"; >> declare namespace custom="http://www.eccnet.com"; >> >> declare function custom:Component($context as node(), $matchedrule as >> element(), $rules as element()+, >> $params as xs:string*)) as element()+ { >> { >> element{QName(http://www.w3.org/1999/xhtml", "p")} >> <xhtml:b>Component: </xhtml:b>map:get($context/string()) >> } >> }; >> >> <!-- Modification in config.xqy --> >> >> (: <render:generic-elem match-name="Component" match-ns="" tag="p" >> xmlns:render="http://marklogic.com/renderapi"/>:) >> >> <render:custom match-name="Component" match-ns="" >> xmlns:render="http://marklogic.com/renderapi"> >> <render:apply ns="http://www.eccnet.com" name="Component" >> at="/lib/custom.xqy"/> >> </render:custom> >> >> TIA >> >> Betty >> >>> >>> Hi Betty, >>> >>> You might consider using the "render:custom" tag rather than overriding >>> the generic-elem function. If the "render:custom" element does not >>> offer >>> you enough granularity and you would like go beyond the rendering of a >>> single XML element by tagname, then you may want to go the path of >>> overriding the functions of standard.xqy directly. I've included an >>> explanation on the usage of each of these below. They are preferable >>> to >>> editing the "render:generic-elem" directly. Feedback about the >>> explanations would be much appreciated - they may possibly get included >>> in >>> future documentation. Let me know what you think. >>> >>> Cheers, >>> David >>> >>> >>> Overriding a Function from "standard.xqy" >>> >>> You can override a function in standard.xqy by editing the variable for >>> the related function in config.xqy. >>> >>> For example, say I want to entirely change the function for the footer. >>> I >>> find the following lines in config.xqy: >>> >>> declare variable $footer := >>> xdmp:function( >>> fn:QName( >>> "http://marklogic.com/appservices/component", "footer")); >>> >>> And I change it to: >>> >>> declare variable $footer := >>> xdmp:function( >>> fn:QName( >>> "http://mycompany.com/custom-app", "custom-footer"), >>> "/lib/extension.xqy"); >>> >>> Then, add the "custom-footer" function in "/lib/extension.xqy". The >>> function "asc:footer" in standard.xqy will no longer be used. >>> >>> >>> Custom Rendering >>> >>> On the "Content" screen of the Applicaiton Builder, you are able to >>> specify how certain XML elements get translated into XHTML (ex: each >>> element <section> should be rendered as a <div>). Sometimes you want to >>> have more control over how this XHTML gets rendered. The >>> "render:custom" >>> tag allows you to do just that. >>> >>> In /application/lib/config.xqy, you will find a variable named >>> $TRANSFORMS. Within the element $TRANSFORMS, you will find elements >>> with >>> the namespace prefix "render". If you see the XML QName that you are >>> interested in as one of the "render" elements (based on the >>> @match-ns/@match-name attributes), then you can change the element tag >>> name to "render:custom". If you do not see such an element, then you >>> can >>> add your own "render:custom" element as a sibling of the "render" >>> elements. >>> >>> Each element with QName "render:custom" must have a child element with >>> QName "render:apply" that has the attributes @ns (function namespace), >>> @name (function name), and @at (library module) to specify the function >>> name and library module for the custom rendering. >>> >>> Let's step through a basic example. >>> >>> I have used entity enrichment to mark up the text of my documents, and >>> one >>> of the marked up items are URLs which get marked up with the namespace >>> "http://marklogic.com/entity" and tag name "url". An example is: >>> >>> <e:url >>> xmlns:e="http://marklogic.com/entity">http://marklogic.com</e:url> >>> >>> On the "Content" page, we specified that this QName should be rendered >>> as >>> a span, so we end up with the following element within the $TRANSFORMS >>> variable in config.xqy: >>> >>> <render:generic-elem match-name="url" >>> match-ns="http://marklogic.com/entity" tag="span" >>> xmlns:render="http://marklogic.com/renderapi"/> >>> >>> This "render" element will cause the example URL above to be rendered >>> as: >>> >>> <span>http://marklogic.com</span> >>> >>> However, we want the URL to be rendered with an "a" tag and @href >>> attribute, like this: >>> >>> <a href="http://marklogic.com">Mark Logic Corporation</a> >>> >>> To do this, we replace the "render:generic-elem" element with the >>> "render:custom" element below: >>> >>> <render:custom match-name="url" >>> match-ns="http://marklogic.com/entity" >>> xmlns:render="http://marklogic.com/renderapi"> >>> <render:apply ns="http://mycompany.com/custom-app" >>> name="link-render" at="/lib/extension.xqy" /> >>> </render:custom> >>> >>> Notice that we no longer need the @tag attribute. >>> >>> Within the file "/lib/extension.xqy" (which is a file that was added >>> after >>> the project was compiled), we have the function custom:link-render >>> (where >>> the namespace prefix "custom" corresponds to the namespace >>> "http://mycompany.com/custom-app"). This function looks like this: >>> >>> declare function custom:link-render($context as node(), $matchedrule as >>> element(), $rules as element()+, $params as xs:string*) >>> as element(a) >>> { >>> element {QName("http://www.w3.org/1999/xhtml","a")} { >>> attribute href { concat(if (not(starts-with($context/string(), >>> "http://"))) then "http://" else (), $context/string()) }, >>> map:get($URL-MAP, $context/string()) >>> } >>> }; >>> >>> Parameters: >>> >>> $context - the XML element to be transformed Example: >>> >>> <e:url >>> xmlns:e="http://marklogic.com/entity">http://marklogic.com</e:url> >>> >>> $matchedrule - the element with QName "render:custom" that represents >>> the >>> custom transformation Example: >>> >>> <render:custom match-name="url" >>> match-ns="http://marklogic.com/entity" >>> xmlns:render="http://marklogic.com/renderapi"> >>> <render:apply ns="http://marklogic.com/appservices/component" >>> name="link-render" at="/lib/extension.xqy" /> >>> </render:custom> >>> >>> $rules - a sequence of all the elements from the $TRANSFORMS variable >>> with >>> namespace "render" that refer to rules for tranformation >>> >>> $params - this variable must be included in the function signature. >>> However, for the purposes of extending a generated application, this >>> parameter should not be used within the function itself. >>> >>> >>> >>> >>> David Amusin >>> Software Engineer >>> Mark Logic Corporation >>> 999 Skyway Road >>> Suite 200 >>> San Carlos, CA 94070 >>> +1 650 207 2308 Cell >>> +1 650 655 2310 Fax >>> [email protected] >>> www.marklogic.com >>> >>> >>> >>> This e-mail and any accompanying attachments are confidential. The >>> information is intended solely for the use of the individual to whom it >>> is >>> addressed. Any review, disclosure, distribution, or use of this e-mail >>> communication by others is strictly prohibited. If you are not the >>> intended recipient, please notify us by returning this message to the >>> sender and delete all copies. Thank you for your cooperation. >>> >>> >>> >>> >>> >>> >>> >>>> ________________________________________ >>>> From: [email protected] >>>> [[email protected] >>>> ] On Behalf Of Betty Harvey [[email protected]] >>>> Sent: Tuesday, June 30, 2009 1:27 PM >>>> To: General Mark Logic Developer Discussion >>>> Subject: [MarkLogic Dev General] Best Approach for Formatting >>>> Content From Application Builder >>>> >>>> I have started building an application using Application Builder. >>>> For most of my elements modifying the <render:generic-elem> tag along >>>> with CSS modifications work. >>>> >>>> There are some cases where I need more granularity in formatting. >>>> The documentation doesn't specify how to modify the <item-detail> >>>> component in the config.xqy file: >>>> >>>> <item-detail> >>>> <render:generic-elem match-name="Revision" match-ns="" tag="tr" >>>> xmlns:render="http://marklogic.com/renderapi"/> >>>> </item-detail> >>>> >>>> I need to do more manipulation of what goes into table cells that our >>>> outside the sequential flow of the information. >>>> >>>> Any advice/hints/tips is appreciated! >>>> >>>> Thanks! >>>> >>>> >>>> /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/ >>>> Betty Harvey | Phone: 410-787-9200 FAX: 9830 >>>> Electronic Commerce Connection, Inc. | >>>> [email protected] | Washington,DC XML Users Grp >>>> URL: http://www.eccnet.com | http://www.eccnet.com/xmlug/ >>>> /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\\/\/ >>>> _______________________________________________ >>>> General mailing list >>>> [email protected] >>>> http://xqzone.com/mailman/listinfo/general >>> >>> >>> _______________________________________________ >>> General mailing list >>> [email protected] >>> http://xqzone.com/mailman/listinfo/general >>> >> >> >> /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/ >> Betty Harvey | Phone: 410-787-9200 FAX: 9830 >> Electronic Commerce Connection, Inc. | >> [email protected] | Washington,DC XML Users Grp >> URL: http://www.eccnet.com | http://www.eccnet.com/xmlug/ >> /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\\/\/ >> _______________________________________________ >> General mailing list >> [email protected] >> http://xqzone.com/mailman/listinfo/general >> _______________________________________________ >> General mailing list >> [email protected] >> http://xqzone.com/mailman/listinfo/general >> > > > /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/ > Betty Harvey | Phone: 410-787-9200 FAX: 9830 > Electronic Commerce Connection, Inc. | > [email protected] | Washington,DC XML Users Grp > URL: http://www.eccnet.com | http://www.eccnet.com/xmlug/ > /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\\/\/ > _______________________________________________ > General mailing list > [email protected] > http://xqzone.com/mailman/listinfo/general > _______________________________________________ > General mailing list > [email protected] > http://xqzone.com/mailman/listinfo/general > /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/ Betty Harvey | Phone: 410-787-9200 FAX: 9830 Electronic Commerce Connection, Inc. | [email protected] | Washington,DC XML Users Grp URL: http://www.eccnet.com | http://www.eccnet.com/xmlug/ /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\\/\/ _______________________________________________ General mailing list [email protected] http://xqzone.com/mailman/listinfo/general
