elements

xml – Call REST Request inside XSLT and copy only some elements


I am attempting to make a REST call inside my XSL that will incorporate only parts of the response into the original transformed XML doc. I found one example that talked about using variables and the document() function, but I can’t seem to get it to work.

Here is the original XML document:

<?xml version="1.0" encoding="UTF-8"?>
<PublishPELTEST xmlns="http://www.ibm.com/maximo" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
creationDateTime="2018-02-08T09:15:08-05:00" transLanguage="EN" 
baseLanguage="EN" messageID="1518099308834189587" maximoVersion="7 5 2 12" 
event="0">
  <PELTESTSet>
    <WORKORDER>
      <DESCRIPTION>My Workorder Description</DESCRIPTION>
      <WONUM>MWO-522</WONUM>
      <WOPRIORITY>3</WOPRIORITY>
      <WORKORDERID>2255202</WORKORDERID>
      <ASSIGNMENT>
        <LABORCODE>006325</LABORCODE>
      </ASSIGNMENT>
      <KUBROUNDENTRY>
        <KUBROUNDENTRYID>267433</KUBROUNDENTRYID>
        <LINEID>254735</LINEID>
        <OBSERVATION />
        <KUBROUNDLINE>
          <ASSETNUM>385691</ASSETNUM>
          <METERNAME>VLOPSTAT</METERNAME>
          <SEQUENCE>90</SEQUENCE>
          <ASSET>
            <ASSETID>388391</ASSETID>
            <DESCRIPTION>Asset Description</DESCRIPTION>
            <SERVICEADDRESS>
              <STREETADDRESS>1234 Kingston Pike</STREETADDRESS>
            </SERVICEADDRESS>
          </ASSET>
          <METER>
            <DOMAINID>VLOPSTAT</DOMAINID>
            <METERNAME>VLOPSTAT</METERNAME>
          </METER>
        </KUBROUNDLINE>
      </KUBROUNDENTRY>
      <KUBROUNDENTRY>
        <KUBROUNDENTRYID>267432</KUBROUNDENTRYID>
        <LINEID>254734</LINEID>
        <OBSERVATION />
        <KUBROUNDLINE>
          <ASSETNUM>385691</ASSETNUM>
          <METERNAME>GLEAKGRD</METERNAME>
          <SEQUENCE>80</SEQUENCE>
          <ASSET>
            <ASSETID>388391</ASSETID>
            <DESCRIPTION>Asset2 Description</DESCRIPTION>
            <SERVICEADDRESS>
              <STREETADDRESS>2345 Kingston Pike</STREETADDRESS>
            </SERVICEADDRESS>
          </ASSET>
          <METER>
            <DOMAINID>CASEGRDE</DOMAINID>
            <METERNAME>GLEAKGRD</METERNAME>
          </METER>
        </KUBROUNDLINE>
      </KUBROUNDENTRY>
    </WORKORDER>
  </PELTESTSet>
</PublishPELTEST>

This is the REST request and the result that is returned normally:
http://server.loc.org/maxrest/rest/mbo/alndomain/?domainid=’SKIPRSN’

<?xml version="1.0" encoding="UTF-8"?>
<ALNDOMAINMboSet rsStart="0" xmlns="http://www.ibm.com/maximo" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <ALNDOMAIN xmlns="http://www.ibm.com/maximo" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
        <DOMAINID>KUBSKIPRSN</DOMAINID>
        <VALUE>TRAFFIC</VALUE>
        <DESCRIPTION>Traffic Control Needed</DESCRIPTION>
        <ALNDOMAINID>4906</ALNDOMAINID>
        <VALUEID>KUBSKIPRSN|TRAFFIC</VALUEID>
    </ALNDOMAIN>
    <ALNDOMAIN xmlns="http://www.ibm.com/maximo" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
        <DOMAINID>KUBSKIPRSN</DOMAINID>
        <VALUE>NOT FOUND</VALUE>
        <DESCRIPTION>Asset Not Found</DESCRIPTION>
        <ALNDOMAINID>4006</ALNDOMAINID>
        <VALUEID>KUBSKIPRSN|NOT FOUND</VALUEID>
    </ALNDOMAIN>
    <ALNDOMAIN xmlns="http://www.ibm.com/maximo" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
        <DOMAINID>KUBSKIPRSN</DOMAINID>
        <VALUE>SKIP ALL</VALUE>
        <DESCRIPTION>Skip All</DESCRIPTION>
        <ALNDOMAINID>3802</ALNDOMAINID>
        <VALUEID>KUBSKIPRSN|SKIP ALL</VALUEID>
    </ALNDOMAIN>
</ALNDOMAINMboSet>

What I had read previously about this was that you had to add the namespace to your xsl. In this case, I believe the namespace is the same namespace as my origianl XML document. So, I guessed that no other references were necessary.??

With that assumption, I ran the XSL below and it does not pull back any information related to the REST request.

<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:mea="http://www.ibm.com/maximo" exclude-result-prefixes="mea"
    version="1.0">
    <xsl:output method="xml" cdata-section-elements="" />

    <xsl:template match="/">
      <yyy:createJob xmlns:yyy="http://place.org/mmm/app">
        <job>
          <id />
          <origin>AMS</origin>
          <metaId>
            <xsl:value-of select="descendant::mea:WORKORDERID" />
          </metaId>
          <title>
            <xsl:value-of select="descendant::mea:DESCRIPTION" />
          </title>
          <dispatchGroup>FWSAMS</dispatchGroup>
          <priority>
            <xsl:value-of select="descendant::mea:WOPRIORITY" />
          </priority>
          <assignedTo>
            <xsl:value-of 
                select="descendant::mea:ASSIGNMENT/mea:LABORCODE" />
          </assignedTo>
          <jobDocument>
            <xsl:text disable-output-escaping="yes">&lt;![CDATA[</xsl:text>
              <root>
                <workorderNum>
                  <xsl:value-of select="descendant::mea:WONUM" />
                </workorderNum>
                <xsl:apply-templates mode="copy"
                      select="descendant::mea:KUBROUNDENTRY" />
                <skipReasonDomain>
                  <xsl:variable name="myDomain">
                    <xsl:text>SKIPRSN</xsl:text>
                  </xsl:variable>
                  <xsl:value-of 
 select="document(concat('http://server.loc.org/maxrest/rest/mbo/alndomain/?
 domainid=',$myDomain))/descendant::VALUE"/>
                </skipReasonDomain>
              </root>
              <xsl:text disable-output-escaping="yes">]]&gt;</xsl:text>
            </jobDocument>
            <completionDocument />
          </job>
        </yyy:createJob>
      </xsl:template>

    <xsl:template match="*" mode="copy">
    <xsl:element name="{local-name()}">
        <xsl:apply-templates select="node()" mode="copy" />
    </xsl:element>
    </xsl:template>

    <xsl:template match="text()|comment()" mode="copy">
      <xsl:copy/>
    </xsl:template>

</xsl:stylesheet>

This is the resulting XML document:

<yyy:createJob
xmlns:yyy="http://place.org/mmm/app">
<job>
    <id></id>
    <origin>AMS</origin>
    <metaId>2255202</metaId>
    <title>My Workorder Description</title>
    <dispatchGroup>FWSAMS</dispatchGroup>
    <priority>3</priority>
    <assignedTo>006325</assignedTo>
    <jobDocument>
        <![CDATA[<root><workorderNum>MWO-522</workorderNum><KUBROUNDENTRY><KUBROUNDENTRYID>267433</KUBROUNDENTRYID><LINEID>254735</LINEID><OBSERVATION/><KUBROUNDLINE><ASSETNUM>385691</ASSETNUM><METERNAME>VLOPSTAT</METERNAME><SEQUENCE>90</SEQUENCE><ASSET><ASSETID>388391</ASSETID><DESCRIPTION>Asset Description</DESCRIPTION><SERVICEADDRESS><STREETADDRESS>1234 Kingston Pike</STREETADDRESS></SERVICEADDRESS></ASSET><METER><DOMAINID>VLOPSTAT</DOMAINID><METERNAME>VLOPSTAT</METERNAME></METER></KUBROUNDLINE></KUBROUNDENTRY><KUBROUNDENTRY><KUBROUNDENTRYID>267432</KUBROUNDENTRYID><LINEID>254734</LINEID><OBSERVATION/><KUBROUNDLINE><ASSETNUM>385691</ASSETNUM><METERNAME>GLEAKGRD</METERNAME><SEQUENCE>80</SEQUENCE><ASSET><ASSETID>388391</ASSETID><DESCRIPTION>Asset2 Description</DESCRIPTION><SERVICEADDRESS><STREETADDRESS>2345 Kingston Pike</STREETADDRESS></SERVICEADDRESS></ASSET><METER><DOMAINID>CASEGRDE</DOMAINID><METERNAME>GLEAKGRD</METERNAME></METER></KUBROUNDLINE></KUBROUNDENTRY><skipReasonDomain/></root>]]>
    </jobDocument>
    <completionDocument></completionDocument>
</job>
</yyy:createJob>

My desired output would be:

<yyy:createJob
xmlns:yyy="http://place.org/mmm/app">
<job>
    <id></id>
    <origin>AMS</origin>
    <metaId>2255202</metaId>
    <title>My Workorder Description</title>
    <dispatchGroup>FWSAMS</dispatchGroup>
    <priority>3</priority>
    <assignedTo>006325</assignedTo>
    <jobDocument>
        <![CDATA[<root><workorderNum>MWO-522</workorderNum><KUBROUNDENTRY><KUBROUNDENTRYID>267433</KUBROUNDENTRYID><LINEID>254735</LINEID><OBSERVATION/><KUBROUNDLINE><ASSETNUM>385691</ASSETNUM><METERNAME>VLOPSTAT</METERNAME><SEQUENCE>90</SEQUENCE><ASSET><ASSETID>388391</ASSETID><DESCRIPTION>Asset Description</DESCRIPTION><SERVICEADDRESS><STREETADDRESS>1234 Kingston Pike</STREETADDRESS></SERVICEADDRESS></ASSET><METER><DOMAINID>VLOPSTAT</DOMAINID><METERNAME>VLOPSTAT</METERNAME></METER></KUBROUNDLINE></KUBROUNDENTRY><KUBROUNDENTRY><KUBROUNDENTRYID>267432</KUBROUNDENTRYID><LINEID>254734</LINEID><OBSERVATION/><KUBROUNDLINE><ASSETNUM>385691</ASSETNUM><METERNAME>GLEAKGRD</METERNAME><SEQUENCE>80</SEQUENCE><ASSET><ASSETID>388391</ASSETID><DESCRIPTION>Asset2 Description</DESCRIPTION><SERVICEADDRESS><STREETADDRESS>2345 Kingston Pike</STREETADDRESS></SERVICEADDRESS></ASSET><METER><DOMAINID>CASEGRDE</DOMAINID><METERNAME>GLEAKGRD</METERNAME></METER></KUBROUNDLINE></KUBROUNDENTRY><skipReasonDomain><VALUE>TRAFFIC</VALUE><VALUE>NOT FOUND</VALUE><VALUE>SKIP ALL</VALUE></root>]]>
    </jobDocument>
    <completionDocument></completionDocument>
</job>
</yyy:createJob>

I know this is a lot of information, but I hope it helps someone to understand what I am trying to do and how I might be able to get there. Any information is much appreciated.



لینک منبع

How to choose the first “n” elements in R


(USING R)
So I imported a data set by using

xcars <- read.csv(file.choose()) 

and then I chose my data set which was originally an excel file.
So, I have a column named dist (short for displacement) and I want to choose the first 25 entries underneath that column and then plot it on a histogram, so I attempted the following.

carsUpTo25 <- xcars(1:25,)
hist(carsUpTo25$dist)

Of course this didn’t work. However, any help on how I would do this would be helpful.



لینک منبع

javascript – Can’t access node buffer elements — returning undefined


I have input Readable stream coming in via an external node library and I am trying to read and convert the buffer to something else for my program.

input.on(‘data’, function(data){
console.log(data); //returns <Buffer 73 fe 74 fe 95 fe 95 fe b6 fe b6 fe 00 ff 01 ff 37 ff 36 ff 8f ff 8f ff 10 00 10 00 65 00 66 00 95 00 95 00 79 00 7a 00 1b 00 1a 00 be ff be ff 56 ff ... >

console.log(data.buffer); // returns — ArrayBuffer { byteLength: 300 }

console.log(data.buffer.length); //returns undefined
console.log(data.buffer[0]); //returns undefined
});

If the data.buffer is an ArrayBuffer, why am I not able to access it at all?



لینک منبع

javascript – Delete HTML elements with JS. WORKING JSFIDDLE


$('#addEnv').click(function() {
  $('#envVariablesDiv').append('<div class="col-sm-5 top10"><div class="input-group"><label class="input-group-addon">Name</label><input id="envName" class="form-control" name="envName" type="text" placeholder="e.g. name1" /></div></div>' +
    '<div class="col-sm-5 top10"><div class="input-group"><label class="input-group-addon">Variable</label><input class="form-control" id="envVar" type="text" name="envVar" placeholder="e.g. var1" /></div></div><div class="col-sm-2 top10"><button type="button" class="btn btn-danger deleteEnv"><span class="fa fa-trash">Delete</span></button></div>');
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

<button id="addEnv">Add</button>
<div id="envVariablesDiv">

</div>



لینک منبع

html – Jquery Remove elements including parent element


I want to remove elements from my page. I want to remove all .Panel elements which do not also have the .SelectedPanel class.

$('.Panel :not(.SelectedPanel)').remove();

I have tried the above, which works, but leaves the parent col divs – I want to remove these as well. So with the markup below, I want the middle column to be removed.

<div class='row'>                
    <div class='col-xs-6 col-sm-1'>
        <div class='Panel SelectedPanel'>
            ....
        </div>
    </div>
    <div class='col-xs-6 col-sm-1'>
        <div class='Panel'>
            ....
        </div>
    </div>
    <div class='col-xs-6 col-sm-1'>
        <div class='Panel SelectedPanel'>
            ....
        </div>
    </div>
</div>



لینک منبع

postgresql – how to extract jsonB array elements with using GIN index


Am using 9.4 postgres

Create table temp_JsonB (ID serial , name_it jsonb);

insert into temp_JsonB (name_it) values ('[{"a":"foo"},{"b":"bar"},{"c":"baz"}]');
insert into temp_JsonB (name_it) values ('[{"c":"foo"},{"d":"hee"},{"c":"baz"}]');
insert into temp_JsonB (name_it) values ('[{"g":"ggo"},{"b":"bar"},{"c":"raz"}]');

CREATE INDEX temp_jsonb_gin
  ON temp_JsonB
  USING gin
  (name_it jsonb_path_ops);

select ID, jsonb_agg(obj)
from temp_JsonB , jsonb_array_elements(name_it) obj
where obj ->>'b' ='bar'
group by 1;

I need to get only the particular element in the array, i used the above method to get it but unfortunately it is not making use of the index, Is there any way where i can re-write the code so it make use of index.

as in original production it has 2000+ rows and takes time, so index can be helpful here



لینک منبع

javascript – Why these pixel-equivalent elements have different real size?


I´m trying to code blog and i want to synchronise positions of timeline events and it´s posts. I coded it as two different columns and I´m trying to get height of post with jQuery and then count the size of blank space in timeline event. Everything seems to be set OK, console gives me equivalent numbers and so the programmer tools in chrome. You can see the height of the post here and these are heights of elements next to it: element1, element2, element3. Together, it 740px but the main element-post is also 740px.

So, I would like to know, how is this possible? Thank you.



لینک منبع

jquery – Count of elements not updating


I have this function in a view:

function checkForAnswers() {
    var count = $('.checklist-<%= document.id %>[value!=""]').length;
    var total = $('.checklist-<%= document.id %>').length;

    if (count == total) {
        $('.high-res-<%= document.id %>').removeClass('disabled');
        $('.high-res-<%= document.id %>').removeAttr('disabled');
    } else {
        $('.high-res-<%= document.id %>').addClass('disabled');
        $('.high-res-<%= document.id %>').attr('disabled', 'disabled');
    }
        console.log(count + '/' + total);
    }
}

checkForAnswers();
$('.checklist-<%= document.id %>').on('keyup', checkForAnswers);

You can see I’m logging the count and the total. Each .checklist element is a text field. Why won’t the count variable increase when I fill out .checklist items? It just logs 0/5 no matter what I do. Any help?



لینک منبع

css – Z-index doesn’t work with flex elements?


I’m trying to have two columns, one beeing a menu which can expand and overlap the other column. But I used a flex element to wrap these columns and my menu expands behind the other element, even with a greater z-index.

The render is something like this:

.main {
  font-family: 'Open Sans', Helvetica, sans-serif;
  display: flex;
  background-color: #99baef;
}

nav {
  height: 100%;
  width: 8em;
  background-color: black;
  z-index: 1;
}

.navbox {
  box-sizing: border-box;
  background-color: black;
  color: white;
  height: 4em;
  width: 100%;
  text-align: center;
  line-height: 4em;
  border-top: 1px dotted #99baef;
  transition: all 1s;
}

.navbox:hover {
  width: 130%;
  border-top: none;
  background-color: #4a77c4;
  color: black;
}

.container {
  padding: 1em;
}

a {text-decoration: inherit;}
<div class="main">
  <div class="maincolumn">
    <nav>
      <a href="">
        <div class="navbox">
          Nav 1
        </div>
      </a>
      <a href="">
        <div class="navbox">
          Nav 2
        </div>
      </a>
    </nav>
  </div>
  <div class="maincolumn">
    <div class="container">
      <h2>Titre</h2>
      <p>This is a text.</p>
    </div>
  </div>
</div>

See ? I want my menu to overlap the rest of my page when expanding. How can I do that, please ?



لینک منبع

javascript – Event binding on dynamically created elements?


As of jQuery 1.7 you should use jQuery.fn.on:

$(staticAncestors).on(eventName, dynamicChild, function() {});

Prior to this, the recommended approach was to use live():

$(selector).live( eventName, function(){} );

However, live() was deprecated in 1.7 in favour of on(), and completely removed in 1.9. The live() signature:

$(selector).live( eventName, function(){} );

… can be replaced with the following on() signature:

$(document).on( eventName, selector, function(){} );

For example, if your page was dynamically creating elements with the class name dosomething you would bind the event to a parent which already exists, often document.

$(document).on('mouseover mouseout', '.dosomething', function(){
    // what you want to happen when mouseover and mouseout 
    // occurs on elements that match '.dosomething'
});

Any parent that exists at the time the event is bound is fine. For example

$('.buttons').on('click', 'button', function(){
    // do something here
});

would apply to

<div class="buttons">
    <!-- <button>s that are generated dynamically and added here -->
</div>



لینک منبع