Tag Archives: XSLT

XSLT u kampjuni jQuery

I ġew jagħmlu ħafna ta XSLT u jQuery u ħsibt I d jaqsmu siltiet ftit li oħrajn jistgħu jsibu utli fil-futur.

Eżempju 1: Jarmu JavaScript sempliċi / jQuery fil XSLT:

<XSL:mudell logħba = "xi ħaġa,,en,tip iskrittura = "test / javascript",,en,"#QueryFriendlyFilters",,en,"Vojta",,en,div id = "fdcAllFilters",,en,jekk test = "@ Għadd,,en,span class = "fdcFilterLabel",,en,għal-kull tagħżel = "UserFilter",,en,klassi = "FilterHref,,en,href = "javascript,,en,"RemoveUserFilter",,en,valur tal agħżel = "@ FilterValue" /,,en,kummenti lill XSLT u kampjuni jQuery,,en,Andres,,en,Awissu 30,,en,Nista 'nuża dan l-approċċ biex jiffiltraw webparts lista multipli SharePoint permezz ta' XSLT,,en,Huwa qedem f'dan il-punt u so I mhux se nipprova,,en" xml:space="preserve">

  <!– Blank l-filtri friendly qasam moħbija query –>
  <script type="text/javascript">
    $(dokument).lest(funzjoni(){
      $("#QueryFriendlyFilters").val("empty");
    });
  </iskrittura>

</XSL:template>

Li ftit temetti xi JavaScript li tistenna l-paġna biex jintemm tagħbija (minħabba l- $(dokument).lest(...)) u mbagħad tistabbilixxi l-valur ta 'qasam moħbija jismu QueryFriendlyFilters għall-valur letterali "vojta".

Eżempju 2: Użu <XSL:jekk> biex jiċċekkjaw "akbar minn",  "Inqas minn", eċċ.

<XSL:mudell logħba = "xi ħaġa,,en,tip iskrittura = "test / javascript",,en,"#QueryFriendlyFilters",,en,"Vojta",,en,div id = "fdcAllFilters",,en,jekk test = "@ Għadd,,en,span class = "fdcFilterLabel",,en,għal-kull tagħżel = "UserFilter",,en,klassi = "FilterHref,,en,href = "javascript,,en,"RemoveUserFilter",,en,valur tal agħżel = "@ FilterValue" /,,en,kummenti lill XSLT u kampjuni jQuery,,en,Andres,,en,Awissu 30,,en,Nista 'nuża dan l-approċċ biex jiffiltraw webparts lista multipli SharePoint permezz ta' XSLT,,en,Huwa qedem f'dan il-punt u so I mhux se nipprova,,en" xml:space="preserve">

  <div id="fdcAllFilters">
 
    <XSL:if test="@Count>0">
      <span class="fdcFilterLabel">Filtri kurrenti:</medda>
    </XSL:jekk>

    <!– Jittieħed aktar jiġri hawn. –>

</XSL:template>

Il-snippet hawn fuq kontrolli biex tara jekk attribut imsejjaħ "Count" tal-element "xi ħaġa" huwa akbar minn zero.  Il-XML wara dan tkun xi ħaġa simili:"

<xi ħaġa Count = "5" />

Eżempju 3: Jtenni permezz elementi kollha, interspersing sejħiet jQuery.

<!– Jtenni kollha permezz tal-filtri u juru l-korretta  rabtiet. –>
<XSL:for-each select="UserFilter">

  <a class="FilterHref" href="javascript:mySubmitPage(‘RemoveUserFilter’,"{@ID}")">[X]</a>

  <span class="fdcFilterLabel"><XSL:value-of select="@FilterValue"/></medda>

  <script type="text/javascript">

    $(dokument).lest(funzjoni(){
        <XSL:test><![CDATA[$("#QueryFriendlyFilters").val( ($("#QueryFriendlyFilters").val() + " ]]></XSL:test>\"<XSL:value-of select="@FilterValue"/>\"<XSL:test><![CDATA["));]]></XSL:test>
    });

  </iskrittura>

</XSL:għal-kull>

Il-snippet hawn fuq huwa ferm aktar kumpless u jista 'jkun hemm modi iktar faċli biex tagħmel dan.

Il-XML wara dan jistenna madwar bħal dan:

<UserFilter ID = "123" FilterValue = "xyzzy" />

Dan snippet hija mtennija permezz <User Iffiltra> nodes. 

L-ewwel temetti ankra tag li meta għafast jinvoka funzjoni JavaScript li huwa diġà fis-paġna, "MySubmitPage" u jgħaddi l-valur ta 'attribut fuq il- <User Iffiltra> node imsejjaħ "ID". 

Imbagħad temetti ftit jQuery li tistenna l-paġna għal tagħbija.  Li l-aġġornamenti jQuery qasam moħbija imsejjaħ "QueryFriendlyFilters" billi żżid il-valur ta 'l-attribut FilterValue.  Innota l-crazy <XSL:test> u <![CDATA[ ... ]]> Jittieħed.

Li huwa, tama dan jgħin!

</aħħar>

Abbona għall-blog tiegħi.

Follow lili Twitter fi http://www.twitter.com/pagalvin

Endlessly jbejtu <div> Tags u jQuery

Din tidher qisha tali suġġett oddball, M'inix ċert li huwa verament jiswa blogging dwar, iżda li qatt ma waqfet lili qabel, hekk here we go Tbissem

Jien jaħdmu fuq proġett fejn jien ġbid xi data minn tfittxija, packaging it up into an XML message and then that XML is ultimately transformed into HTML via XSLT.  There’s a lot of jQuery involved, one bit of which implements some tabbing functionality.  When you click on a tab (verament, a <div>), jQuery invokes .hide() and .show() on various divs (the initial page load downloads all the content so there are no postbacks in this case).

A bunch of hours ago, the tab switching logic started to behave erratically and it wouldn’t show one of my tabs.  I ultimately tracked it down to the fact that internet explorer (inqas) thought that the <div> tags nested far, far deeper than intended.The developer toolbar would show:

-<div id=”Tab1Content”>
  -<div>
    -<div>
      -<div id=”Tab2Content”>
        -<div>
           …………………………
                   </div>  <—finally showing it was closed all the way down here!

Allura, if I did a $(“#Tab1Content”).hide(), I’d also hide Tab2 and I could never show Tab2 if I didn’t also show Tab1.  I copied and pasted the code up into visual studio and it showed all of the div’s lining up nicely, just like they were supposed to be doing, looking like this:

-<div id=”Tab1Content”>
  +<div>
  +<div>
-<div id=”Tab2Content”>
  +<div>
  +<div>

I beat my head against the wall for a while and noticed that in the actual HTML code was generating a lot of empty <div> tags, like:

<korp>

  <div id=”Tab1Content”>

    <div id=”row1” />
    <div id=”row2” />

  </div>

  <div id=”Tab2Content”>

    <div id=”row1” />
    <div id=”row2” />

  </div>

</korp>

(The above is waaaaaaaaaaaay oversimplified.  The empty div tags are totally valid. Some of my <div> tags were full of content, but many more were not.  I came to the realization that my <XSL:għal-kull> directives were emitting the short-form div tags when the xsl:for-each didn’t’ find any data.  I forced an HTML comment into the output, kif muri:

image

 

After I did that, all the div’s lined up nicely and my tab switching started working.

As always, I hope this helps someone in a pinch.

</aħħar>

Abbona għall-blog tiegħi.

Follow lili Twitter fi http://www.twitter.com/pagalvin

Eżempju: XSLT Ħolqien HTML Href tal

Stajt kont qed tagħmel daqsxejn ta 'għalf XSL aħħar u ħsibt I d tpoġġi flimkien kampjun għal referenza futura tiegħi u li jistgħu jkunu ta' valur għalina lkoll XSLT-hom teħid ta 'għajxien fil-internets.

Ikkunsidra l-XML ġej:

<FdcSearchTabsCollection Count="2">
  <SearchTab Label="Industry" SortOrder=”00” Label=”Industries” SearchConstraints="contenttype:Industrija" TabID="831b2a74-98c4-4453-8061-86e2fdb22c63"/>
  <SearchTab Label="Practices" SortOrder=”01” Label=”Practices” SearchConstraints="contenttype:PracticeGroups" TabID="678e206b-6996-421f-9765-b0558fe1a9c0"/>
</FdcSearchTabsCollection>

Il snippet XSL ġej ser jiġġenera lista magħżula ta 'tabs hrefs:

<XSL:template match="FdcSearchTabsCollection" xml:space="preserve">
   
    <!– The "all" tab –>
    <a href="javascript:ViewTab(‘All’)">Ara kollox</a>
   
    <!– Kull tab individwali –>
    <!– Jtenni permezz kollha Tabs u juru l-korretta  rabtiet. –>
    <XSL:for-each select="SearchTab">
      <XSL:sort select="@SortOrder"/>

      …
      <a href="javascript:ViewTab("{@TabID}")"><XSL:value-of select="@Label"/></a>
    </XSL:għal-kull>

    <br /> 
   

   </XSL:template>

Hawn dak li jidher qisu fil SharePoint:

SNAGHTML78aa2cb

 

 

</aħħar>

Abbona għall-blog tiegħi.

Follow lili Twitter fi http://www.twitter.com/pagalvin