I have duplicate entry in my xml column in my sql table see material8 key.I remove one entry.I am trying below query its removing both.Is there any way i can remove only one entry.
Update mytable set xml = replace (xml, "<Book key=\"material8\" active=\"true\" displayOrder=\"5\" />", "") where id = 9 and type_key="mykey1";
<?xml version="1.0" encoding="UTF-8"?>
<Type key="test1" publicKey="test2" >
<UIProperties>
<label locale="en_US">My book</label>
</UIProperties>
<Books>
<Book key="material1" active="true" displayOrder="0" >
<UIProperties>
<label locale="en_US">My Books</label>
</UIProperties>
</Book>
<Book key="material2" />
<Book key="material3" active="true" displayOrder="3" >
<Pages>
<Page key="material4" active="true" displayOrder="0" />
<Page key="material5" active="true" displayOrder="1" />
</Pages>
</Book>
<Book key="material6" active="true" displayOrder="4" />
<Book key="material7" active="true" displayOrder="2" />
<Book key="material8" active="true" displayOrder="5" />
<Book key="material8" active="true" displayOrder="5" />
</Books>
<Attributes>
<Attribute key="desc" />
<Attribute key="date1" />
<Attribute key="date2" />
</Attributes>
</Type>
A simple solution is to replace 2 books to 1, instead of 1 to none:
UPDATE mytable
SET xml = REPLACE(xml, "<Book key=\"material8\" active=\"true\" displayOrder=\"5\" /><Book key=\"material8\" active=\"true\" displayOrder=\"5\" />", "<Book key=\"material8\" active=\"true\" displayOrder=\"5\" />")
WHERE id = 9
AND type_key="mykey1";
Related
declare #xml xml = '<?xml version="1.0"?> <dashboardsettings> <widgets>
<widget userwidgetuniqueid="9" widgetid="9" daterange="1" startdate="2016-02-06" enddate="2017-02-06" />
<widget userwidgetuniqueid="10" widgetid="10" daterange="0" startdate="2016-02-06" enddate="2017-02-06" />
<widget userwidgetuniqueid="11" widgetid="11" daterange="0" startdate="2016-02-06" enddate="2017-02-06" />
<widget userwidgetuniqueid="12" widgetid="12" daterange="3" />
<widget userwidgetuniqueid="13" widgetid="13" daterange="3" /> </widgets> </dashboardsettings>'
We wanted to add extra node to this xml (at last or first does not matter)
output to be as
declare #xml xml =
'
<?xml version="1.0"?>
<dashboardsettings>
<widgets>
<widget userwidgetuniqueid="9" widgetid="9" daterange="1" startdate="2016-02-06" enddate="2017-02-06" />
<widget userwidgetuniqueid="10" widgetid="10" daterange="0" startdate="2016-02-06" enddate="2017-02-06" />
<widget userwidgetuniqueid="11" widgetid="11" daterange="0" startdate="2016-02-06" enddate="2017-02-06" />
<widget userwidgetuniqueid="12" widgetid="12" daterange="3" />
<widget userwidgetuniqueid="13" widgetid="13" daterange="3" />
<widget userwidgetuniqueid="14" widgetid="14" daterange="3" />
</widgets>
</dashboardsettings>
'
--then
i wrote code to find max value of userwidgetuniqueid and adding +1 and prepared new node also but i could not add this new node to xml value , the error
says : Incorrect use of the XML data type method 'modify'. A non-mutator method is expected in this context.
--below is my code
declare #TopUserwidgetuniqueid int
SELECT top 1 #TopUserwidgetuniqueid = x.y.value('.','int')
FROM #XML.nodes('/dashboardsettings/widgets/widget/#userwidgetuniqueid') AS x ( y )
order by x.y.value('.','int') desc
select #TopUserwidgetuniqueid=#TopUserwidgetuniqueid+1
declare #xNewNode xml = '<widget widgetid="'+cast(#TopUserwidgetuniqueid as varchar(10)) +'" daterange="2"></widget>'
SET #xml = #xml.modify('insert sql:variable("#xNewNode") as last into /dashboardsettings/widgets[1]')
select #xml
The last xml.modify to insert new node is not working , please help ,
Many thanks.
I am sending the following XML query to EWS using the Office.context.mailbox.makeEwsRequestAsync method.
The query string value needs to either match the subject or the from field; and the emails must belong the "MY_CATEGORY" category. I am unable to enforce the last requirement. What am I doing wrong?
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Header>
<t:RequestServerVersion Version="Exchange2013_SP1" />
</soap:Header>
<soap:Body>
<m:FindItem Traversal="Shallow">
<m:ItemShape>
<t:BaseShape>AllProperties</t:BaseShape>
</m:ItemShape>
<m:IndexedPageItemView MaxEntriesReturned="10" Offset="0" BasePoint="Beginning" />
<m:Restriction>
<t:Or>
<t:Contains ContainmentMode="Substring" ContainmentComparison="IgnoreCase">
<t:FieldURI FieldURI="item:Subject" />
<t:Constant Value="query string" />
</t:Contains>
<t:Contains ContainmentMode="Substring" ContainmentComparison="IgnoreCase">
<t:FieldURI FieldURI="message:From" />
<t:Constant Value="query string" />
</t:Contains>
</t:Or>
<t:And>
<t:Contains ContainmentMode="FullString" ContainmentComparison="IgnoreCase">
<t:FieldURI FieldURI="item:Categories" />
<t:Constant Value="MY_CATEGORY" />
</t:Contains>
</t:And>
</m:Restriction>
<m:ParentFolderIds>
<t:DistinguishedFolderId Id="inbox" />
<t:DistinguishedFolderId Id="sentitems" />
</m:ParentFolderIds>
</m:FindItem>
</soap:Body>
</soap:Envelope>
Categories are Multivalued strings so the searchfilters your using won't work on these types of values. You can AQS on Exchange 2010 and above to search the Categories as well as the other fields your search on. eg
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Header>
<t:RequestServerVersion Version="Exchange2013_SP1" />
</soap:Header>
<soap:Body>
<m:FindItem Traversal="Shallow">
<m:ItemShape>
<t:BaseShape>IdOnly</t:BaseShape>
<t:AdditionalProperties>
<t:FieldURI FieldURI="item:Subject" />
<t:FieldURI FieldURI="item:DisplayTo" />
<t:FieldURI FieldURI="item:DisplayCc" />
<t:FieldURI FieldURI="item:DateTimeReceived" />
<t:FieldURI FieldURI="item:HasAttachments" />
<t:FieldURI FieldURI="item:ItemClass" />
</t:AdditionalProperties>
</m:ItemShape>
<m:IndexedPageItemView MaxEntriesReturned="250" Offset="0" BasePoint="Beginning" />
<m:SortOrder>
<t:FieldOrder Order="Ascending">
<t:FieldURI FieldURI="contacts:DisplayName" />
</t:FieldOrder>
</m:SortOrder>
<m:ParentFolderIds>
<t:FolderId Id="AQ..." />
</m:ParentFolderIds>
<m:QueryString>System.Category:Green AND (From:'Glen Scales' OR Subject:test) </m:QueryString>
</m:FindItem>
</soap:Body>
</soap:Envelope>
I'm trying to import a submission.xml file generated from an ODK survey into Access. I'm using the 'XML import' function in MS Access and need to transform the data so that the each data set of a node that will be imported to a table will contain the ID of the survey.
I have a XML with the survey data that looks like this:
<SoLa_Tu_Insp_2016-03-13 id="SOLA-160313"
instanceID="uuid:63c27738-df02-4298-9090-7ab96d4e1ab2"
submissionDate="2016-04-08T02:11:47.600Z"
isComplete="true"
markedAsCompleteDate="2016-04-08T02:13:12.322Z"
xmlns="http://opendatakit.org/submissions">
<start>2016-04-08T23:47:50.615Z</start>
<end>2016-04-08T02:11:30.954Z</end>
<deviceid>353375050176865</deviceid>
<telnr />
<insp>
<objekt>25</objekt>
<objdel>212</objdel>
<objdel-tx>Bronstunneln</objdel-tx>
<datum>2016-04-08</datum>
<sign>MFR RLS</sign>
<anm>8</anm>
</insp>
<skdr>
<skd>
<metod>100</metod>
<ts>
<ts-nr>523</ts-nr>
<ts-typskada>Lucka - Lös - Takelement</ts-typskada>
<ts-kdel>15</ts-kdel>
<ts-kelem>1530</ts-kelem>
<ts-mtrl>13</ts-mtrl>
<ts-typ>35</ts-typ>
<ts-orsak>999</ts-orsak>
<ts-aktivitet>87</ts-aktivitet>
<ts-enhet>st</ts-enhet>
<ts-aktivitet-tx>Åtdragning</ts-aktivitet-tx>
<ts-mangd>1.0000000000</ts-mangd>
</ts>
<ovr>
<ovr-kdel />
<ovr-kdel-tx />
<ovr-kelem />
<ovr-kelem-tx />
<ovr-mtrl />
<ovr-mtrl-tx />
<ovr-typ />
<ovr-typ-tx />
<ovr-orsak />
<ovr-aktivitet />
<ovr-aktivitet-tx />
<ovr-enhet />
<ovr-mangd />
</ovr>
<kdel>15</kdel>
<kelem>1530</kelem>
<mtrl>13</mtrl>
<typ>35</typ>
<orsak>999</orsak>
<skd-tx>Gång/inspektionsbrygga etc / Lucka/dörr / Rostfritt stål / Lös / Övrigt</skd-tx>
<tk>3</tk>
<anm>Luckan håller på att ramla av</anm>
<aktivitet>87</aktivitet>
<mangd>1</mangd>
<enhet>st</enhet>
<sekt1>675</sekt1>
<sekt2 />
<lage>VT</lage>
<lage-tx />
<bildskada>1460073108135.jpg</bildskada>
<bildnr />
</skd>
<skd>
<metod>100</metod>
<ts>
<ts-nr>321</ts-nr>
<ts-typskada>f.a. sprutbetong - Läckage - Tak</ts-typskada>
<ts-kdel>6</ts-kdel>
<ts-kelem>665</ts-kelem>
<ts-mtrl>6</ts-mtrl>
<ts-typ>50</ts-typ>
<ts-orsak>129</ts-orsak>
<ts-aktivitet>45</ts-aktivitet>
<ts-enhet>kg</ts-enhet>
<ts-aktivitet-tx>Injektering</ts-aktivitet-tx>
<ts-mangd>5.0000000000</ts-mangd>
</ts>
<ovr>
<ovr-kdel />
<ovr-kdel-tx />
<ovr-kelem />
<ovr-kelem-tx />
<ovr-mtrl />
<ovr-mtrl-tx />
<ovr-typ />
<ovr-typ-tx />
<ovr-orsak />
<ovr-aktivitet />
<ovr-aktivitet-tx />
<ovr-enhet />
<ovr-mangd />
</ovr>
<kdel>6</kdel>
<kelem>665</kelem>
<mtrl>6</mtrl>
<typ>50</typ>
<orsak>129</orsak>
<skd-tx>Huvudbärverk / Tak ytförstärkning / Fiberarmerad sprutbetong / Läckage / Vatten</skd-tx>
<tk>2</tk>
<anm>3/s</anm>
<aktivitet>45</aktivitet>
<mangd>5</mangd>
<enhet>kg</enhet>
<sekt1>694</sekt1>
<sekt2>694</sekt2>
<lage>CT</lage>
<lage-tx>Kalk, järn,mangan utfälning droppar rikligt</lage-tx>
<bildskada />
<bildnr>4517</bildnr>
</skd>
<skd>
<metod>100</metod>
<ts>
<ts-nr>321</ts-nr>
<ts-typskada>f.a. sprutbetong - Läckage - Tak</ts-typskada>
<ts-kdel>6</ts-kdel>
<ts-kelem>665</ts-kelem>
<ts-mtrl>6</ts-mtrl>
<ts-typ>50</ts-typ>
<ts-orsak>129</ts-orsak>
<ts-aktivitet>45</ts-aktivitet>
<ts-enhet>kg</ts-enhet>
<ts-aktivitet-tx>Injektering</ts-aktivitet-tx>
<ts-mangd />
</ts>
<ovr>
<ovr-kdel />
<ovr-kdel-tx />
<ovr-kelem />
<ovr-kelem-tx />
<ovr-mtrl />
<ovr-mtrl-tx />
<ovr-typ />
<ovr-typ-tx />
<ovr-orsak />
<ovr-aktivitet />
<ovr-aktivitet-tx />
<ovr-enhet />
<ovr-mangd />
</ovr>
<kdel>6</kdel>
<kelem>665</kelem>
<mtrl>6</mtrl>
<typ>50</typ>
<orsak>129</orsak>
<skd-tx>Huvudbärverk / Tak ytförstärkning / Fiberarmerad sprutbetong / Läckage / Vatten</skd-tx>
<tk>1</tk>
<anm>Kalk, järn,mangan utfälning</anm>
<aktivitet>45</aktivitet>
<mangd />
<enhet>kg</enhet>
<sekt1>698</sekt1>
<sekt2 />
<lage>VT</lage>
<lage-tx>8/sek</lage-tx>
<bildskada />
<bildnr>4519-4520</bildnr>
</skd>
<skd>
<metod>100</metod>
<ts>
<ts-nr>513</ts-nr>
<ts-typskada>Lucka - Defekt - Takelement</ts-typskada>
<ts-kdel>15</ts-kdel>
<ts-kelem>1530</ts-kelem>
<ts-mtrl>13</ts-mtrl>
<ts-typ>48</ts-typ>
<ts-orsak>999</ts-orsak>
<ts-aktivitet>88</ts-aktivitet>
<ts-enhet>st</ts-enhet>
<ts-aktivitet-tx>Översyn</ts-aktivitet-tx>
<ts-mangd />
</ts>
<ovr>
<ovr-kdel />
<ovr-kdel-tx />
<ovr-kelem />
<ovr-kelem-tx />
<ovr-mtrl />
<ovr-mtrl-tx />
<ovr-typ />
<ovr-typ-tx />
<ovr-orsak />
<ovr-aktivitet />
<ovr-aktivitet-tx />
<ovr-enhet />
<ovr-mangd />
</ovr>
<kdel>15</kdel>
<kelem>1530</kelem>
<mtrl>13</mtrl>
<typ>48</typ>
<orsak>999</orsak>
<skd-tx>Gång/inspektionsbrygga etc / Lucka/dörr / Rostfritt stål / Defekt / Övrigt</skd-tx>
<tk>2</tk>
<anm>Går ej skruva saknas 2st skruvar</anm>
<aktivitet>88</aktivitet>
<mangd />
<enhet>st</enhet>
<sekt1>653</sekt1>
<sekt2 />
<lage>HT</lage>
<lage-tx>Nya skruvhål luckan som matchar</lage-tx>
<bildskada />
<bildnr>4523-4521</bildnr>
</skd>
<skd>
<metod>100</metod>
<ts>
<ts-nr>513</ts-nr>
<ts-typskada>Lucka - Defekt - Takelement</ts-typskada>
<ts-kdel>15</ts-kdel>
<ts-kelem>1530</ts-kelem>
<ts-mtrl>13</ts-mtrl>
<ts-typ>48</ts-typ>
<ts-orsak>999</ts-orsak>
<ts-aktivitet>88</ts-aktivitet>
<ts-enhet>st</ts-enhet>
<ts-aktivitet-tx>Översyn</ts-aktivitet-tx>
<ts-mangd>1.0000000000</ts-mangd>
</ts>
<ovr>
<ovr-kdel />
<ovr-kdel-tx />
<ovr-kelem />
<ovr-kelem-tx />
<ovr-mtrl />
<ovr-mtrl-tx />
<ovr-typ />
<ovr-typ-tx />
<ovr-orsak />
<ovr-aktivitet />
<ovr-aktivitet-tx />
<ovr-enhet />
<ovr-mangd />
</ovr>
<kdel>15</kdel>
<kelem>1530</kelem>
<mtrl>13</mtrl>
<typ>48</typ>
<orsak>999</orsak>
<skd-tx>Gång/inspektionsbrygga etc / Lucka/dörr / Rostfritt stål / Defekt / Övrigt</skd-tx>
<tk>2</tk>
<anm>Luckan behövs passas om</anm>
<aktivitet>88</aktivitet>
<mangd>1</mangd>
<enhet>st</enhet>
<sekt1>681</sekt1>
<sekt2 />
<lage>VT</lage>
<lage-tx>TV3 tidigare 2 skruv har sätts men mådet åtgärdas</lage-tx>
<bildskada />
<bildnr>4527</bildnr>
</skd>
<skd>
<metod>100</metod>
<ts>
<ts-nr>513</ts-nr>
<ts-typskada>Lucka - Defekt - Takelement</ts-typskada>
<ts-kdel>15</ts-kdel>
<ts-kelem>1530</ts-kelem>
<ts-mtrl>13</ts-mtrl>
<ts-typ>48</ts-typ>
<ts-orsak>999</ts-orsak>
<ts-aktivitet>88</ts-aktivitet>
<ts-enhet>st</ts-enhet>
<ts-aktivitet-tx>Översyn</ts-aktivitet-tx>
<ts-mangd>1.0000000000</ts-mangd>
</ts>
<ovr>
<ovr-kdel />
<ovr-kdel-tx />
<ovr-kelem />
<ovr-kelem-tx />
<ovr-mtrl />
<ovr-mtrl-tx />
<ovr-typ />
<ovr-typ-tx />
<ovr-orsak />
<ovr-aktivitet />
<ovr-aktivitet-tx />
<ovr-enhet />
<ovr-mangd />
</ovr>
<kdel>15</kdel>
<kelem>1530</kelem>
<mtrl>13</mtrl>
<typ>48</typ>
<orsak>999</orsak>
<skd-tx>Gång/inspektionsbrygga etc / Lucka/dörr / Rostfritt stål / Defekt / Övrigt</skd-tx>
<tk>3</tk>
<anm />
<aktivitet>88</aktivitet>
<mangd>1</mangd>
<enhet>st</enhet>
<sekt1>710</sekt1>
<sekt2 />
<lage>HT</lage>
<lage-tx>Nedre skruvhål passar inte</lage-tx>
<bildskada />
<bildnr>4543-4542</bildnr>
</skd>
</skdr>
<ritningar>212B2B01 212B2B02 212B2B03 212B2B04</ritningar>
<skd-antal>6</skd-antal>
<sekt-min>653</sekt-min>
<sekt-max>710</sekt-max>
<tk-min>1</tk-min>
<tk-max>3</tk-max>
<n0:meta xmlns:n0="http://openrosa.org/xforms">
<n0:instanceID>uuid:63c27738-df02-4298-9090-7ab96d4e1ab2</n0:instanceID>
<n0:instanceName>SöLä-25-212-2016-04-08-MFR RLS-4ae669a1-7d89-424a-bfab-26d506da0604</n0:instanceName>
</n0:meta>
At each 'skd' node I want to add the 'instanceID' attribute of the root element so that each 'skd' node will look something like:
<skdr>
<skd>
<id>uuid:63c27738-df02-4298-9090-7ab96d4e1ab2</id>
<metod>100</metod>
So I'm trying to use this XSL-file for the transformation, which is not working as intended:
xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output indent="yes" encoding="utf-8"/>
<xsl:strip-space elements="*"/>
<xsl:template match="/">
<dataroot>
<xsl:apply-templates select="#*|node()"/>
</dataroot>
</xsl:template>
<xsl:template match="#*|node()">
<xsl:copy>
<xsl:apply-templates select="#*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="//skd">
<xsl:copy>
<xsl:apply-templates select="#*|node()"/>
<ID><xsl-copy-of select="/SoLa_Tu_Insp_2016-03-13/#instanceID"/></ID>
<xsl:apply-templates select="node()"/>
</xsl:copy>
</xsl:template>
The result I get when using the above transformation is like this:
<?xml version="1.0" encoding="utf-8"?>
<dataroot>
<SoLa_Tu_Insp_2016-03-13 xmlns="http://opendatakit.org/submissions" id="SOLA-160313" instanceID="uuid:63c27738-df02-4298-9090-7ab96d4e1ab2" submissionDate="2016-04-08T02:11:47.600Z" isComplete="true" markedAsCompleteDate="2016-04-08T02:13:12.322Z">
<start>2016-04-08T23:47:50.615Z</start>
<end>2016-04-08T02:11:30.954Z</end>
<deviceid>353375050176865</deviceid>
<telnr/>
<insp>
<objekt>25</objekt>
<objdel>212</objdel>
<objdel-tx>Bronstunneln</objdel-tx>
<datum>2016-04-08</datum>
<sign>MFR RLS</sign>
<anm>8</anm>
</insp>
<skdr>
<skd>
<metod>100</metod>
<ts>
<ts-nr>523</ts-nr>
<ts-typskada>Lucka - Lös - Takelement</ts-typskada>
<ts-kdel>15</ts-kdel>
<ts-kelem>1530</ts-kelem>
<ts-mtrl>13</ts-mtrl>
<ts-typ>35</ts-typ>
<ts-orsak>999</ts-orsak>
<ts-aktivitet>87</ts-aktivitet>
<ts-enhet>st</ts-enhet>
<ts-aktivitet-tx>Åtdragning</ts-aktivitet-tx>
<ts-mangd>1.0000000000</ts-mangd>
</ts>
Thers is no 'instanceID' at each 'skd' node. I've tested the XPATHs at http://www.freeformatter.com/xpath-tester.html and it seems to be OK.
Anyone have any idea what I'm doing wrong here?
Your template does not match the skd element in the source XML document, because that element is in a namespace.
Try it this way instead:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:odk="http://opendatakit.org/submissions"
exclude-result-prefixes="odk">
<xsl:output indent="yes" encoding="utf-8"/>
<xsl:strip-space elements="*"/>
<xsl:template match="/">
<dataroot>
<xsl:apply-templates select="#*|node()"/>
</dataroot>
</xsl:template>
<xsl:template match="#*|node()">
<xsl:copy>
<xsl:apply-templates select="#*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="odk:skd">
<xsl:copy>
<xsl:apply-templates select="#*"/>
<ID xmlns="http://opendatakit.org/submissions">
<xsl:value-of select="/odk:SoLa_Tu_Insp_2016-03-13/#instanceID"/>
</ID>
<xsl:apply-templates select="node()"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
Additional notes:
Starting a match pattern with // is redundant;
xsl-copy-of is not a valid XSLT instruction;
Your version <xsl:apply-templates select="#*|node()"/> would have duplicated the child nodes.
I've been trying to create a SCORM 1.2 manifest file that will create multiple SCOs with sub-files but, although there's plenty written about it online, I've been unable to find any actual examples. Essentially, what I want to do is:
SCO1.html
SCO1.1.html
SCO1.2.html
SCO1.3.html
SCO2.html
SCO2.1.html
SCO2.2.html
SCO2.3.html
In the above scenario, if the user was to launch SCO1.2.html, for example, their progress would be recorded against SCO1. I've got the following in my imsmanifest.xml file, but don't know how to restructure it so that each item is not a separate SCO. I've left out the metadata and resources that don't affect this issue:
<organizations default="TOC1">
<organization identifier="TOC1">
<title>Test</title >
<item identifier="I_SCO1" identifierref="SCO1">
<title>SCO1</title>
</item>
<item identifier="I_SCO1.1" identifierref="SCO1.1">
<title>SCO1.1</title>
</item>
<item identifier="I_SCO1.2" identifierref="SCO1.2">
<title>SCO1.2</title>
</item>
<item identifier="I_SCO1.3" identifierref="SCO1.3">
<title>SCO1.3</title>
</item>
<item identifier="I_SCO2" identifierref="SCO2">
<title>SCO2</title>
</item>
<item identifier="I_SCO2.1" identifierref="SCO2.1">
<title>SCO2.1</title>
</item>
<item identifier="I_SCO2.2" identifierref="SCO2.2">
<title>SCO2.2</title>
</item>
<item identifier="I_SCO2.3" identifierref="SCO2.3">
<title>SCO2.3</title>
</item>
</organization>
</organizations>
<resources>
<resource identifier="SCO1" type="webcontent" adlcp:scormtype="sco" href="SCO1.html">
<file href="SCO1.html" />
<dependency identifierref="ALLRESOURCES" />
</resource>
<resource identifier="SCO1.1" type="webcontent" adlcp:scormtype="sco" href="SCO1.1.html">
<file href="SCO1.1.html" />
<dependency identifierref="ALLRESOURCES" />
</resource>
<resource identifier="SCO1.2" type="webcontent" adlcp:scormtype="sco" href="SCO1.2.html">
<file href="SCO1.2.html" />
<dependency identifierref="ALLRESOURCES" />
</resource>
<resource identifier="SCO1.3" type="webcontent" adlcp:scormtype="sco" href="SCO1.3.html">
<file href="SCO1.3.html" />
<dependency identifierref="ALLRESOURCES" />
</resource>
<resource identifier="SCO2" type="webcontent" adlcp:scormtype="sco" href="SCO2.html">
<file href="SCO2.html" />
<dependency identifierref="ALLRESOURCES" />
</resource>
<resource identifier="SCO2.1" type="webcontent" adlcp:scormtype="sco" href="SCO2.1.html">
<file href="SCO2.1.html" />
<dependency identifierref="ALLRESOURCES" />
</resource>
<resource identifier="SCO2.2" type="webcontent" adlcp:scormtype="sco" href="SCO2.2.html">
<file href="SCO2.2.html" />
<dependency identifierref="ALLRESOURCES" />
</resource>
<resource identifier="SCO2.3" type="webcontent" adlcp:scormtype="sco" href="SCO2.3.html">
<file href="SCO2.3.html" />
<dependency identifierref="ALLRESOURCES" />
</resource>
</resources>
Any help would be appreciated.
You'll be looking at something a little closer to this-
<organizations default="ORG-001">
<organization identifier="ORG-001">
<title>Page Progression Sample</title>
<item>
<title>Module 1</title>
<item identifier="ACT-001" identifierref="RES-001">
<title>Name of this page</title>
</item>
<item identifier="ACT-002" identifierref="RES-002">
<title>Name of this page</title>
</item>
<item identifier="ACT-003" identifierref="RES-003">
<title>Name of this page</title>
</item>
<item identifier="ACT-004" identifierref="RES-004">
<title>Name of this page</title>
</item>
</item>
<item>
<title>Module 2</title>
<item identifier="ACT-005" identifierref="RES-005">
<title>Name of this page</title>
</item>
<item identifier="ACT-006" identifierref="RES-006">
<title>Name of this page</title>
</item>
<item identifier="ACT-007" identifierref="RES-007">
<title>Name of this page</title>
</item>
<item identifier="ACT-008" identifierref="RES-008">
<title>Name of this page</title>
</item>
</item>
</organization>
But you could try nesting 2, 3, 4 within 1 to see if that works. I don't have the specification in front of me right now.
In your example -
<item identifier="I_SCO1" identifierref="SCO1">
<title>SCO1</title>
<!-- PUT YOUR NEXT SCO (page) HERE-->
</item> <!-- Close tag of SCO1 -->
I have few questions conserning XSLT to html conversion.
For some reason my xsl documents makes extra rows between every for-each loop. What can be the problem? Problem can be seen in html outputs.
Here's my xslt file
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="html" encoding="utf-8" media-type="text/html" />
<xsl:template match="/">
<html>
<head>
<title>KT-linjan moduulit</title>
</head>
<body>
<h1>KT-linja info</h1>
<table border="double">
<caption>Moduulit taulukoituna</caption>
<tr>
<th>identifier</th>
<th>nimi</th>
<th>kuvaus</th>
</tr>
<xsl:for-each select="production_line/unit/*">
<tr>
<td>
<xsl:value-of select="#modID" />
</td>
<td>
<xsl:value-of select="name" />
</td>
<td>
<xsl:value-of select="description" />
</td>
</tr>
</xsl:for-each>
</table>
<p>
<b>HUOM:</b>
</p>
<p>ID's of the modules are unique!</p>
<p>References between modules are correct!</p>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
and XML file:
<production_line>
<unit>
<lift_module modID="LM001">
<name>Päätynostin PN1</name>
<description lang="fi">Nostaa paletin alakuljettimelta ylös Starter-moduulille</description>
<conveyor type="BELT" level="down" feed="in">
<description lang="fi">Palettikuljetin (ala)</description>
<stopper />
</conveyor>
<conveyor type="BELT" level="up" feed="out">
<description lang="fi">Palettikuljetin (ylä)</description>
<stopper />
</conveyor>
<lift_shelf>
<conveyor feed="in_out" type="BAND">
<description lang="fi">Palettikuljetin (hissitaso)</description>
<stopper />
</conveyor>
<description lang="fi">Liikkuva hissitaso</description>
</lift_shelf>
<sensor type="INDUCTIVE">
<amount>2</amount>
</sensor>
<chassis type="SAFETY" width="500" heigth="1200" length="700">
<sensor type="OPTIC">
<amount>1</amount>
</sensor>
</chassis>
</lift_module>
<connection fromIDREF="LM001" toIDREF="SM001" />
</unit>
<unit>
<starter_module modID="SM001">
<name>Starter-moduuli ST1</name>
<description lang="fi">Jakaa paletit kolmelle kuljettimelle</description>
<conveyor type="BELT">
<description lang="fi">Palettikuljetin (keski)</description>
<stopper />
</conveyor>
<conveyor type="BELT">
<description lang="fi">Palettikuljetin (syöttö1)</description>
<stopper />
</conveyor>
<conveyor type="BELT">
<description lang="fi">Palettikuljetin (syöttö2)</description>
<stopper />
</conveyor>
<crossing />
<crossing />
<crossing />
<sensor type="INDUCTIVE">
<amount>3</amount>
</sensor>
<sensor type="OPTIC">
<amount>3</amount>
</sensor>
</starter_module>
<connection fromIDREF="SM001" toIDREF="WM001" />
</unit>
<unit>
<workstation modID="WM001">
<name>Työasema TA1</name>
<description lang="fi">Sisältää vasemman ja oikean työpisteen</description>
<conveyor type="BELT">
<description lang="fi">Palettikuljetin (keski)</description>
<stopper />
</conveyor>
<conveyor type="BELT">
<description lang="fi">Palettikuljetin (vasen)</description>
<stopper>stoppari</stopper>
</conveyor>
<conveyor type="BELT">
<description lang="fi">Palettikuljetin (oikea)</description>
<stopper />
</conveyor>
<crossing />
<crossing />
<crossing />
<sensor type="INDUCTIVE">
<amount>6</amount>
</sensor>
<sensor type="OPTIC">
<amount>6</amount>
</sensor>
<switch type="push_button" operate="manual">send-painike</switch>
<switch type="switch" operate="manual">pause-kytkin</switch>
</workstation>
<connection fromIDREF="WM001" toIDREF="LM002" />
</unit>
<unit>
<lift_module modID="LM002">
<name>Päätynostin PN2</name>
<description lang="fi">Laskee paletin ylhäältä alas paluukuljettimelle</description>
<conveyor type="BELT" level="down" feed="out">
<description lang="fi">Palettikuljetin (ala)</description>
<stopper />
</conveyor>
<conveyor type="BELT" level="up" feed="in">
<description lang="fi">Palettikuljetin (ylä)</description>
<stopper />
</conveyor>
<lift_shelf>
<description lang="fi">Liikkuva hissitaso</description>
<conveyor type="BELT" feed="in_out">
<description lang="fi">Palettikuljetin (hissitaso)</description>
<stopper />
</conveyor>
</lift_shelf>
<sensor type="INDUCTIVE">
<amount>2</amount>
</sensor>
<chassis type="SAFETY" width="500" heigth="1200" length="700">
<sensor type="OPTIC">
<amount>2</amount>
</sensor>
</chassis>
</lift_module>
</unit>
</production_line>
On left is my table and on the right table in correct format.
I need to check if every identifier has unique attribute name (modID, for example LM001) and post if its unique or not. How should this check be performed?
I also need to check if iDREF atributes in XML file are properly linked. For example in the end of first node there is and check that it is correctly linked to the next modID. Any idea about this one?
It also seems to add unnecessary row between "ID's of the modules are unique!" and "References between modules are correct!" lines (where should be posted the answers of the checks).
Don't do <xsl:for-each select="production_line/unit/*">. That is too unspecific, it also matches the <connection> elements (which generate the empty rows).
Do this instead: <xsl:for-each select="production_line/unit/lift_module">.
To check whether all modID values are uniqe, try to select a duplicate:
<xsl:variable name="duplicateModIds" select="
//*/#modID[
. = preceding::*/#modID
or
. = following::*/#modID
]
" />
<xsl:choose>
<xsl:when test="$duplicateModIds">
<p>IDs of the modules are NOT unique!</p>
<!-- probably output $duplicateModIds, too -->
</xsl:when>
<xsl:otherwise>
<p>IDs of the modules are unique.</p>
</xsl:otherwise>
</xsl:choose>
Note that this can also be solved more elegantly through an XSL key, but for now the "duct tape" solution should be fine. Think about using keys when the performance of your transformation starts to drop or your requirements become more complex.
To check whether all connections are correct, simply try to select an incorrect one:
<xsl:variable name="incorrectRefs" select="
//connection[
#fromIDREF != ../*/#modID
or (
../following-sibling::unit[1]
and #toIDREF != ../following-sibling::unit[1]/*/#modID
)
]
" />
<xsl:choose>
<xsl:when test="$incorrectRefs">
<p>References between modules are NOT correct!</p>
<!-- probably output $incorrectRefs, too -->
</xsl:when>
<xsl:otherwise>
<p>References between modules are correct.</p>
</xsl:otherwise>
</xsl:choose>
also need to check if iDREF atributes in XM