how can i add the namespace name before the attribute in xml using simplexml - simplexml

how can i add namespace name before a attribute of newly created tag,like
<Data ss:Type="String">this the value of data</Data>
but can create only
<Data Type="String">this the value of data</Data>
so i can not add "ss:" before atttbute.
Thanks in Advance
Have Dream Day

In the SimpleXml PHP manual someone gave a good example in the comments section.
Here is how I got it to work.
Say you have the following XML in a file xml.php:
<?php
$string = <<<XML
<Row>
<Cell>
<Data>Dolly Parton</Data>
</Cell>
<Cell>
<Data>Islands in the Stream</Data>
</Cell>
<Cell>
<Data>what</Data>
</Cell>
<Cell>
<Data>1-29-2010</Data>
</Cell>
</Row>
XML;
You can read in this file and add the attributes you want by using XPath.
<?php
include("xml.php");
$sxe = new SimpleXMLElement($string);
$data = $sxe->xpath('//Data');
foreach ($data as $value)
{
$value->addAttribute('ss:Type', 'String', 'http://www.w3.org/2001/XMLSchema-instance');
}
echo $sxe->asXML();
?>
This is the output I get:
<Row>
<Cell>
<Data xmlns:ss="http://www.w3.org/2001/XMLSchema-instance" ss:Type="String">Dolly Parton</Data>
</Cell>
<Cell>
<Data xmlns:ss="http://www.w3.org/2001/XMLSchema-instance" ss:Type="String">Islands in the Stream</Data>
</Cell>
<Cell>
<Data xmlns:ss="http://www.w3.org/2001/XMLSchema-instance" ss:Type="String">what</Data>
</Cell>
<Cell>
<Data xmlns:ss="http://www.w3.org/2001/XMLSchema-instance" ss:Type="String">1-29-2010</Data>
</Cell>
</Row>

Related

Task scheduler-run for event with specific Result Code

I would like to trigger the task only if the login attempt is against a disabled account. This includes the Result Code 0x12. How can I add this to the trigger? Any help would be much appreciated. Thanks.
Link to Screen Cap Of Event Properties
Here is the event details XML View:
- <Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
- <System>
<Provider Name="Microsoft-Windows-Security-Auditing" Guid="{54849625-5478-4994-A5BA-3E3B0328C30D}" />
<EventID>4768</EventID>
<Version>0</Version>
<Level>0</Level>
<Task>14339</Task>
<Opcode>0</Opcode>
<Keywords>0x8010000000000000</Keywords>
<TimeCreated SystemTime="2022-04-19T16:40:04.842900000Z" />
<EventRecordID>562602120</EventRecordID>
<Correlation />
<Execution ProcessID="528" ThreadID="106016" />
<Channel>Security</Channel>
<Computer>XXXXXXXXXX</Computer>
<Security />
</System>
- <EventData>
<Data Name="TargetUserName">XXXXXXXX</Data>
<Data Name="TargetDomainName">XXXXXXX</Data>
<Data Name="TargetSid">S-1-0-0</Data>
<Data Name="ServiceName">krbtgt/mie</Data>
<Data Name="ServiceSid">S-1-0-0</Data>
<Data Name="TicketOptions">0x40810010</Data>
<Data Name="Status">0x12</Data>
<Data Name="TicketEncryptionType">0xffffffff</Data>
<Data Name="PreAuthType">-</Data>
<Data Name="IpAddress">::ffff:192.168.240.79</Data>
<Data Name="IpPort">50126</Data>
<Data Name="CertIssuerName" />
<Data Name="CertSerialNumber" />
<Data Name="CertThumbprint" />
</EventData>
</Event>
Here is a task trigger that includes everything but the result code:
<QueryList>
<Query Id="0" Path="Security">
<Select Path="Security">*[System[band(Keywords,4503599627370496) and (EventID=4768)]]</Select>
</Query>
</QueryList>
Not sure where to put the Result Code 0x12
<Data Name="Status">0x12</Data>

How to apply PlanDefinition inorder to generate a carePlan

I am newbie to FHIR. Trying to create careplan by applying PlanDefinition/$apply. Are there any examples available so that I can take them as reference and generate careplan out of planDefintion.
I am able to post an planDefinition but I don't have any clue on implementing $apply out of it.
There is an implementation of PlanDefinition/$apply here:
https://github.com/DBCG/cqf-ruler/blob/master/r4/src/main/java/org/opencds/cqf/r4/providers/PlanDefinitionApplyProvider.java#L84
Note that there is in-progress work on that provider to make it more modular, but the logic is essentially the same.
Have a look at this example from the FHIR Wiki
Request: Apply the low suicide risk order set to patient 124
GET [base]/PlanDefinition/example/$apply?subject=Patient/124
Response: Returned on successful application of the order set
HTTP/1.1 200 OK
<?xml version="1.0" encoding="UTF-8"?>
<CarePlan xmlns="http://hl7.org/fhir">
<!-- This example demonstrates the result of an $apply operation for the citalopramPrescription activity definition. -->
<id value="apply-operation-response"/>
<text>
<status value="generated"/>
<div xmlns="http://www.w3.org/1999/xhtml">
Generated...
</div>
</text>
<contained>
<ServiceRequest>
<id value="referralrequest"/>
<status value="draft"/>
<intent value="proposal"/>
<code>
<coding>
<system value="http://snomed.info/sct"/>
<code value="306206005"/>
</coding>
<text value="Referral to service (procedure)"/>
</code>
<subject>
<reference value="Patient/124"/>
</subject>
<occurrenceDateTime value="2017-02-26T11:47:00.000Z"/>
<requester>
<reference value="Practitioner/123"/>
</requester>
<performerType>
<coding>
<system value="http://nucc.org/provider-taxonomy"/>
<code value="261QM0850X"/>
<display value="Adult Mental Health"/>
</coding>
</performerType>
<reasonCode>
<coding>
<system value="http://example.org/CodeSystem/suicide-risk-assessment-score"/>
<code value="Low"/>
<display value="Low Suicide Risk"/>
</coding>
<text value="Low Suicide Risk"/>
</reasonCode>
<reasonReference>
<reference value="RiskAssessment/suicide-risk-assessment"/>
</reasonReference>
</ServiceRequest>
</contained>
<contained>
<Medication>
<id value="citalopramMedication"/>
<code>
<coding>
<system value="http://www.nlm.nih.gov/research/umls/rxnorm"/>
<code value="200371"/>
</coding>
<text value="citalopram"/>
</code>
<form>
<coding>
<system value="http://snomed.info/sct"/>
<code value="385055001"/>
<display value="Tablet dose form"/>
</coding>
<text value="Tablet dose form"/>
</form>
<ingredient>
<itemReference>
<reference value="#citalopramSubstance"/>
</itemReference>
<amount>
<numerator>
<value value="20"/>
<unit value="mg"/>
</numerator>
<denominator>
<value value="1"/>
<unit value="{tbl}"/>
</denominator>
</amount>
</ingredient>
</Medication>
</contained>
<contained>
<Substance>
<id value="citalopramSubstance"/>
<code>
<coding>
<system value="http://www.nlm.nih.gov/research/umls/rxnorm"/>
<code value="2556"/>
</coding>
<text value="citalopram"/>
</code>
</Substance>
</contained>
<contained>
<MedicationRequest>
<id value="citalopramPrescription"/>
<status value="draft"/>
<intent value="proposal"/>
<medicationReference>
<reference value="#citalopramMedication"/>
</medicationReference>
<subject>
<reference value="Patient/124"/>
</subject>
<requester>
<reference value="Practitioner/123"/>
</requester>
<reasonCode>
<coding>
<system value="http://example.org/CodeSystem/suicide-risk-assessment-score"/>
<code value="Low"/>
<display value="Low Suicide Risk"/>
</coding>
<text value="Low Suicide Risk"/>
</reasonCode>
<reasonReference>
<reference value="RiskAssessment/suicide-risk-assessment"/>
</reasonReference>
<!--definition>
<reference value="ActivityDefinition/citalopramPrescription"/>
</definition-->
<instantiates value="ActivityDefinition/citalopramPrescription"/>
<dosageInstruction>
<text value="1 tablet oral 1 time daily"/>
<timing>
<repeat>
<frequency value="1"/>
<period value="1"/>
<periodUnit value="d"/>
</repeat>
</timing>
<route>
<coding>
<code value="26643006"/>
<display value="Oral route (qualifier value)"/>
</coding>
<text value="Oral route (qualifier value)"/>
</route>
<doseAndRate>
<type><text value="ordered"/></type>
<doseQuantity>
<value value="1"/>
<unit value="{tbl}"/>
</doseQuantity>
</doseAndRate>
</dosageInstruction>
<dispenseRequest>
<numberOfRepeatsAllowed value="3"/>
<quantity>
<value value="30"/>
<unit value="{tbl}"/>
</quantity>
</dispenseRequest>
</MedicationRequest>
</contained>
<instantiatesCanonical value="PlanDefinition/example"/>
<status value="draft"/>
<intent value="proposal"/>
<subject>
<reference value="Patient/124"/>
</subject>
<activity>
<reference>
<reference value="#referralrequest"/>
</reference>
</activity>
<activity>
<reference>
<reference value="#citalopramPrescription"/>
</reference>
</activity>
</CarePlan>
I am actively looking for the Plandefinition$apply operation usage or implementation.
as #code tutorial meny

How to select the node with grand-grandchild node that has particular value

Hi I just want to get the Element A with value of "123abc" in it. I have tried both but failed.
//Package/A[A/B/C/. = 123abc]
//Package/A[contains(A/B/C,123abc)]
I want it to return this:
<A>
<System mtm="8742" os="Windows XP" oslang="en" />
<System mtm="2055" os="Windows XP" oslang="jp" />
<A>
<B>
<C>123abc</C>
<C>789</C>
<C>567</C>
</B>
</A>
</A>
Sample xml to run query on:
<?xml version="1.0" encoding="UTF-8"?>
<Database version="300">
<Package>
<A>
<System mtm="8742" os="Windows XP" oslang="en" />
<System mtm="2055" os="Windows XP" oslang="jp" />
<A>
<B>
<C>123abc</C>
<C>789</C>
<C>567</C>
</B>
</A>
</A>
</Package>
<Package>
<A>
<System mtm="8742" os="Windows XP" oslang="en" />
<System mtm="2055" os="Windows XP" oslang="jp" />
<A>
<B>
<C>efg123</C>
<C>789</C>
<C>567</C>
</B>
</A>
</A>
</Package>
</Database>
You can test your answer here: http://www.freeformatter.com/xpath-tester.html#ad-output
Added the actual xml i am trying to process, but won't work could it be special characters escaped?
actual xml i am trying to process is below, i have tried
//TableSection/SectionItem[SectionItem/Cell/. = "00-18-E7-17-48-64"]
//TableSection/SectionItem[contains(SectionItem/Cell,"00-18-E7-17-48-64")]
<TableSection name="SNMP Devices" IsTreeFormat="true">
<SectionProperties>
<Column id="1" Name="IP Address" />
<Column id="2" Name="Description" />
</SectionProperties>
<SectionItem>
<Cell columnid="1">
192.168.99.54
</Cell>
<Cell columnid="2">
WMI XScan
</Cell>
<SectionItem>
<Cell columnid="1">
ScanType
</Cell>
<Cell columnid="2">
WMIScan
</Cell>
</SectionItem>
<SectionItem>
<Cell columnid="1">
Device description
</Cell>
<Cell columnid="2">
WMI dscription
</Cell>
</SectionItem>
<SectionItem>
<Cell columnid="1">
MACAddress
</Cell>
<Cell columnid="2">
00-18-E7-17-48-64
</Cell>
</SectionItem>
</SectionItem>
<SectionItem>
<Cell columnid="1">
192.168.99.55
</Cell>
<Cell columnid="2">
WMI XScan
</Cell>
<SectionItem>
<Cell columnid="1">
ScanType
</Cell>
<Cell columnid="2">
WMIScan
</Cell>
</SectionItem>
<SectionItem>
<Cell columnid="1">
Device description
</Cell>
<Cell columnid="2">
WMI dscription
</Cell>
</SectionItem>
<SectionItem>
<Cell columnid="1">
MACAddress
</Cell>
<Cell columnid="2">
90-2B-34-64-16-9D
</Cell>
</SectionItem>
</SectionItem>
<SectionItem>
<Cell columnid="1">
192.168.99.107
</Cell>
<Cell columnid="2">
VMWare : "navvms08.Crest.local"
</Cell>
<SectionItem>
<Cell columnid="1">
MACAddress
</Cell>
<Cell columnid="2">
00-07-E9-0D-05-C5
</Cell>
</SectionItem>
<SectionItem>
<Cell columnid="1">
Device identifier
</Cell>
<Cell columnid="2">
1.3.6.1.4.1.6876.4.1
</Cell>
</SectionItem>
<SectionItem>
<Cell columnid="1">
Device name
</Cell>
<Cell columnid="2">
"navvms08.Crest.local"
</Cell>
</SectionItem>
<SectionItem>
<Cell columnid="1">
Device description
</Cell>
<Cell columnid="2">
"VMware ESXi 5.5.0 build-1623387 VMware, Inc. x86_64"
</Cell>
</SectionItem>
</SectionItem>
</TableSection>
In the original sample you need to quote your comparison string. Both of these work:
//Package/A[A/B/C/. = "123abc"]
//Package/A[contains(A/B/C,"123abc")]
The query for the actual XML you're running against should be:
//TableSection/SectionItem[SectionItem/Cell[contains(.,"00-18-E7-17-48-64")]]
The problem with:
//TableSection/SectionItem[SectionItem/Cell/. = "00-18-E7-17-48-64"]
is that the text content must match exactly, while the XML has leading and trailing whitespace.
The problem with:
//TableSection/SectionItem[contains(SectionItem/Cell,"00-18-E7-17-48-64")]
is that contains() only looks in the first SectionItem/Cell within //TableSection/SectionItem instead of any SectionItem/Cell therein to find the text.
For the first example, you have not quoted the string you are comparing against. Also you do not need the additional /. expressions as the node atomizaton rules will be applied for the string comparison anyway.
The XPath //Package/A[A/B/C = "123abc"] will suffice.
If you want to do a partial match against the text content of C then you could use //Package/A[A/B/C/contains(., "123abc")]. You do need the . in this as you want to find an A element that has a C grand-daughter element which contains the text 123abc. The . refers to the current context, which here is an individual C element.
Otherwise, if you did A/B/contains(C, "123abc") you would get a type error as you have multiple C elements and fn:contains cannot operate on a sequence.
For the second example, the example without contains is a whitespace issue, you could fix this by using contains, however your contains tries to operate on a sequence. Instead you should rework it to something like this:
//TableSection/SectionItem[SectionItem/Cell/contains(., "00-18-E7-17-48-64")]

XPATH expression not respected with filter using variable

There is this XSLT code in one of my projects
<xsl:template match="strategic-objectives/list/item" mode="table-of-contents">
<div class="toc">
<h3 class="report">Strategic objective: <xsl:value-of select="title"/></h3>
<xsl:variable name="flex_value" select="flex_value"/>
<xsl:apply-templates select="//root/data/operational-outcomes/list/item[sf = $flex_value]" mode="table-of-contents"/>
</div>
</xsl:template>
how much ever I try, the data for <operational-outcomes> does not match to sf = flex_value, but sf = '020000' matches.
I have checked the <flex_value> if proper in XML for the <strategic-objectives> item. It in fact also has 020000 as one of the values.
data
<data xsql-timing="3131">
<time>20 of April, 2014 (14:22) </time>
<strategic-objectives>
<list type="strategic_objective" xsql-timing="81">
<item num="1">
<context>PB08V6 </context>
<flex_value_set_name>ILO_AFF_SF </flex_value_set_name>
<attribute5>10 </attribute5>
<flex_value>010000 </flex_value>
<hierarchy_level>1 </hierarchy_level>
<title>Policy Making </title>
</item>
<item num="4">
<context>PB08V6 </context>
<flex_value_set_name>ILO_AFF_SF </flex_value_set_name>
<attribute5>10 </attribute5>
<flex_value>200000 </flex_value>
<hierarchy_level>1 </hierarchy_level>
<title>Employment </title>
<description> </description>
<text> </text>
</item>
</list>
</strategic-objectives>
<operational-outcomes>
<list type="outcome" xsql-timing="477">
<item num="9">
<context>PB08V6 </context>
<flex_value_set_name>ILO_AFF_SF </flex_value_set_name>
<flex_value>220025 </flex_value>
<parent_flex_value>220000 </parent_flex_value>
<hierarchy_level>3 </hierarchy_level>
<status>10 </status>
<attribute5>40 </attribute5>
<title>REVISED - Policies for growth, employment and poverty reduction </title>
<description></description>
<text> </text>
<sf>200000 </sf>
</item>
<item num="10">
<context>PB08V6 </context>
<flex_value_set_name>ILO_AFF_SF </flex_value_set_name>
<flex_value>740050 </flex_value>
<parent_flex_value>740000 </parent_flex_value>
<hierarchy_level>3 </hierarchy_level>
<status>10 </status>
<attribute5>40 </attribute5>
<title>DELETED - Internal Administration and Security </title>
<sf>700000 </sf>
</item>
</list>
</operational-outcomes>
</data>
Looking at your XML source, there's a white-space problem:
<flex_value>200000 </flex_value>
Every character matters, 200000␣␣␣␣ is not the same as 200000.
normalize-whitespace() strips leading and trailing whitespace, and collapses multiple subsequent whitespace characters within a string into one. Example:
<xsl:variable name="flex_value" select="normalize-space(flex_value)"/>
␣␣foo␣␣␣bar␣␣ becomes foo␣bar.

How do i display an image instead of text for a ? on an xml form for ODK collect?

Since odk collect uses utf-8, the language that i would like the questions of the form to be in would be displayed one character at a time vs. conjoined. instead of displaying text for the question, i want the question to display an image which will be on the question text formatted properly. Is there anyway this can be done, are there any good tutorials or information out there that can help me accomplish this?
<h:html xmlns="http://www.w3.org/2002/xforms" xmlns:h="http://www.w3.org/1999/xhtml" xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:jr="http://openrosa.org/javarosa">
<h:head>
<h:title>firstform</h:title>
<model>
<instance>
<data id="build_firstform_1375472795">
<meta>
<instanceID/>
</meta>
<field_name/>
<field_age/>
<field_location/>
</data>
</instance>
<itext>
<translation lang="eng">
<text id="/data/field_name:label">
<value>**<img src="Q1.png" >**</value>
</text>
<text id="/data/field_name:hint">
<value>What is your name (last, first)?</value>
</text>
the bolded code did not work.
<?xml version="1.0" encoding="UTF-8"?>
<h:html xmlns="http://www.w3.org/2002/xforms" xmlns:h="http://www.w3.org/1999/xhtml" xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:jr="http://openrosa.org/javarosa" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><h:head xmlns="">
<h:title>images</h:title><model>
<instance>
<data id="1">
<some_text/>
<image_test/>
</data>
</instance>
<itext>
<translation lang="eng">
<text id="/data/image_test:label">
<value>picture test</value>
</text>
<text id="/data/image_test:a">
<value form="image">jr://images/p1.jpg</value>
</text>
<text id="/data/image_test:b">
<value form="image">jr://images/p2.jpg</value>
</text>
</translation>
</itext>
<bind nodeset="/data/image_test" type="select1"/>
</model>
</h:head>
<h:body xmlns="">
<select1 ref="/data/image_test">
<label ref="jr:itext('/data/image_test:label')"/>
<item>
<label ref="jr:itext('/data/image_test:a')"/>
<value>a</value>
</item>
<item>
<label ref="jr:itext('/data/image_test:b')"/>
<value>b</value>
</item>
<item>
<label ref="jr:itext('/data/image_test:c')"/>
<value>c</value>
</item>
</select1>
</h:body>
</h:html>

Resources