I have a question imagine i have following xml:
<dsQueryResponse>
<Work_Description>
<Rows>
<Row SId="{6EB1996C-8629-4BF9-92CA-956551E8D10D}" Title="DemoV1" />
<Row SId="{6819144E-A9B7-4611-A694-7D2EDBF910A7}" Title="Template 1" />
<Row SId="{2E56B932-F197-4335-AE92-1B5BF23D3EA4}" Title="Template 2" />
</Rows>
</Work_Description>
<Reports>
<Rows>
<Row SId="{6EB1996C-8629-4BF9-92CA-956551E8D10D}" Title="Reports" />
<Row SId="{6EB1996C-8629-4BF9-92CA-956551E8D103}" Title="Reports 2" />
<Row SId="{6EB1996C-8629-4BF9-92CA-956551E8D10S}" Title="Reports 3" />
<Row SId="{6EB1996C-8629-4BF9-92CA-956551E8D10A}" Title="Reports 4" />
</Rows>
</Reports>
</dsQueryResponse>
and in my XSLT i have following:
<xsl:variable name="AllProjects" select="/dsQueryResponse/Work_Description/Rows/Row"/>
<xsl:variable name="AllReports" select="/dsQueryResponse/Reports/Rows/Row"/>
Now i have this 2 arrays how can I get another array filtered where all description rows where repots SId = work SId.
It should be something like this: <xsl:variable="Filtered" select="AllProjects[#SId=$AllReports/#SId]" />
I'm not sure I completely understand your problem... But this is working:
<xsl:variable name="Filtered" select="$AllProjects[#SId=$AllReports/#SId]" />
<xsl:copy-of select="$Filtered"/>
Related
I have this XML file, where I have these nodes:
<Rows>
<Row type="Comment">
<Amount>0.00</Amount>
</Row>
<Row type="Spec">
<Amount>10.00</Amount>
</Row>
<Row type="Spec">
<Amount>10.00</Amount>
</Row>
<Row type="Spec">
<Amount>10.00</Amount>
</Row>
<Row type="Comment">
<Amount>0.00</Amount>
</Row>
<Row type="Spec">
<Amount>20.00</Amount>
</Row>
<Row type="Spec">
<Amount>10.00</Amount>
</Row>
<Row type="Spec">
<Amount>20.00</Amount>
</Row>
</Rows>
The result should be:
COMMENT: 30
COMMENT: 50
These Spec rows will always come after Comment rows. I need to do the sum of those Spec rows which are coming after Comment rows.
I tried to use Preceeding and Following functions in XSLT 1.0 but it is not working:
<xsl:value-of select="sum(../Row[#type='Spec']/Amount][following-sibling::row[1][#type='comment']])"/>
Can someone please help?
I would suggest you try it this way:
XSLT 1.0
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text"/>
<xsl:key name="spec" match="Row[#type='Spec']" use="generate-id(preceding-sibling::Row[#type='Comment'][1])" />
<xsl:template match="Rows">
<xsl:for-each select="Row[#type='Comment']">
<xsl:text>COMMENT: </xsl:text>
<xsl:value-of select="sum(key('spec', generate-id())/Amount)"/>
<xsl:text>
</xsl:text>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
I'm trying to group the input below by the destination and assortment values using muenchian-grouping which is new for me so I'm not sure how to do it properly. The input files will be much larger than this so performance is important.
<?xml version="1.0"?>
<ns0:Data xmlns:ns0="http://BizTalk_Projects.input">
<transports>
<destination>destination 1</destination>
<assortment>Volvo_GA961</assortment>
<quantity>10</quantity>
</transports>
<transports>
<destination>destination 1</destination>
<assortment>Volvo_GA961</assortment>
<quantity>15</quantity>
</transports>
<transports>
<destination>destination 1</destination>
<assortment>Volvo_GA969</assortment>
<quantity>15</quantity>
</transports>
<transports>
<destination>destination 1</destination>
<assortment>Volvo_GA972</assortment>
<quantity>5</quantity>
</transports>
<transports>
<destination>destination 1</destination>
<assortment>Volvo_SA980</assortment>
<quantity>20</quantity>
</transports>
<transports>
<destination>destination 2</destination>
<assortment>Volvo_GA960</assortment>
<quantity>10</quantity>
</transports>
<transports>
<destination>destination 1</destination>
<assortment>Nissan_GA963</assortment>
<quantity>5</quantity>
</transports>
<transports>
<destination>destination 1</destination>
<assortment>Nissan_GA963</assortment>
<quantity>5</quantity>
</transports>
</ns0:Data>
Expected output:
<?xml version="1.0" encoding="UTF-8"?>
<ns0:Destinations xmlns:ns0="http://BizTalk_Projects.output">
<Destination>
<name>destination 1</name>
<assortment>
<name>Volvo_GA</name>
<row>
<type>sumPerAssortment</type>
<id>961</id>
<totalQuantity>25</totalQuantity>
<region>1</region>
</row>
<row>
<type>sumPerAssortment</type>
<id>969</id>
<totalQuantity>15</totalQuantity>
<region>1</region>
</row>
<row>
<type>sumPerAssortment</type>
<id>972</id>
<totalQuantity>5</totalQuantity>
<region>2</region>
</row>
<row>
<type>sumPerRegion</type>
<id />
<totalQuantity>40</totalQuantity>
<region>1</region>
</row>
<row>
<type>sumPerRegion</type>
<id />
<totalQuantity>5</totalQuantity>
<region>2</region>
</row>
<row>
<type>totalSum</type>
<id />
<totalQuantity>45</totalQuantity>
<region />
</row>
</assortment>
<assortment>
<name>Volvo_SA</name>
<row>
<type>sumPerAssortment</type>
<id>980</id>
<totalQuantity>20</totalQuantity>
<region>3</region>
</row>
<row>
<type>sumPerRegion</type>
<id />
<totalQuantity>20</totalQuantity>
<region>3</region>
</row>
<row>
<type>totalSum</type>
<id />
<totalQuantity>20</totalQuantity>
<region />
</row>
</assortment>
<assortment>
<name>Nissan_GA</name>
<row>
<type>sumPerAssortment</type>
<id>963</id>
<totalQuantity>10</totalQuantity>
<region>1</region>
</row>
<row>
<type>sumPerRegion</type>
<id />
<totalQuantity>10</totalQuantity>
<region>1</region>
</row>
<row>
<type>totalSum</type>
<id />
<totalQuantity>10</totalQuantity>
<region />
</row>
</assortment>
</Destination>
<Destination>
<name>destination 2</name>
<assortment>
<name>Volvo_GA</name>
<row>
<type>sumPerAssortment</type>
<id>960</id>
<totalQuantity>10</totalQuantity>
<region>1</region>
</row>
<row>
<type>sumPerRegion</type>
<id />
<totalQuantity>10</totalQuantity>
<region>1</region>
</row>
<row>
<type>totalSum</type>
<id />
<totalQuantity>10</totalQuantity>
<region />
</row>
</assortment>
</Destination>
</ns0:Destinations>
Note:
assortment number starting with 96 = region 1
assortment number starting with 97 = region 2
assortment number starting with 98 = region 3
Start of my XSLT:
<?xml version="1.0" encoding="UTF-16"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt"
xmlns:var="http://schemas.microsoft.com/BizTalk/2003/var"
exclude-result-prefixes="msxsl var s0"
version="1.0"
xmlns:s0="http://BizTalk_Projects.input"
xmlns:ns0="http://BizTalk_Projects.output">
<xsl:output omit-xml-declaration="yes" method="xml" version="1.0" />
<xsl:key name="destinationKey" match="transports" use="destination"/>
<xsl:template match="/">
<xsl:apply-templates select="/s0:Data" />
</xsl:template>
<xsl:template match="/s0:Data">
<ns0:Destinations>
<xsl:for-each select="transports[count(. | key('destinationKey',destination)[1]) = 1]">
<Destination>
<name>
<xsl:value-of select="destination/text()" />
</name>
<xsl:for-each select="key('destinationKey',destination)">
<assortment>
<name>
<xsl:value-of select="substring(assortment/text(),1,string-length(assortment)-3)" />
</name>
</assortment>
</xsl:for-each>
</Destination>
</xsl:for-each>
</ns0:Destinations>
</xsl:template>
</xsl:stylesheet>
With this code, I'm getting this output (duplicate rows, but correct assortments for each destination);
<ns0:Destinations xmlns:ns0="http://BizTalk_Projects.output">
<Destination>
<name>destination 1</name>
<assortment>
<name>Volvo_GA</name>
</assortment>
<assortment>
<name>Volvo_GA</name>
</assortment>
<assortment>
<name>Volvo_GA</name>
</assortment>
<assortment>
<name>Volvo_GA</name>
</assortment>
<assortment>
<name>Volvo_SA</name>
</assortment>
<assortment>
<name>Nissan_GA</name>
</assortment>
<assortment>
<name>Nissan_GA</name>
</assortment>
</Destination>
<Destination>
<name>destination 2</name>
<assortment>
<name>Volvo_GA</name>
</assortment>
</Destination>
</ns0:Destinations>
Any suggestions on how I can solve this? Help is very appreciated!
It's difficult to see how exactly the output relates to the input. Try this as your starting point:
XSLT 1.0
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:key name="transports-by-destination" match="transports" use="destination" />
<xsl:key name="transports-by-assortment" match="transports" use="concat(destination, '|', assortment)" />
<xsl:template match="/*">
<xsl:copy>
<!-- for each unique destination -->
<xsl:for-each select="transports[count(. | key('transports-by-destination', destination)[1]) = 1]">
<Destination>
<name>
<xsl:value-of select="destination"/>
</name>
<xsl:variable name="group" select="key('transports-by-destination', destination)" />
<!-- for each unique assortment in this destination -->
<xsl:for-each select="$group[count(. | key('transports-by-assortment', concat(destination, '|', assortment))[1]) = 1]">
<assortment>
<name>
<xsl:value-of select="assortment"/>
</name>
<!-- process this subgroup -->
<xsl:for-each select="key('transports-by-assortment', concat(destination, '|', assortment))" >
<row>
<!-- not sure what goes in here -->
<totalQuantity>
<xsl:value-of select="quantity"/>
</totalQuantity>
</row>
</xsl:for-each>
</assortment>
</xsl:for-each>
</Destination>
</xsl:for-each>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 3 years ago.
Improve this question
I am creating a database to store the results of tests on machines. Is the schema I propose suitable/the best, or am I completely misunderstanding how to structure databases?
There are different types of machines which require different tests.
These tests use 'stock solutions', which are tested and dated to ensure they are suitable for use.
Some machines have a syringe, which is also tested.
All the tests are conducted in well-plates, so I need to record what the value was for a specific well in a particular plate.
I need to record who undertook the test, so I have included a users table.
My current schema is the following:
And in XML:
(I am using the viewer here WWW SQL Designer.)
<?xml version="1.0" encoding="UTF-8"?>
<!-- SQL XML created by WWW SQL Designer, https://github.com/ondras/wwwsqldesigner/ -->
<!-- Active URL: https://ondras.zarovi.cz/sql/demo/ -->
<sql>
<datatypes db="mysql">
<group label="Numeric" color="rgb(238,238,170)">
<type label="Integer" length="0" sql="INTEGER" quote="" />
<type label="TINYINT" length="0" sql="TINYINT" quote="" />
<type label="SMALLINT" length="0" sql="SMALLINT" quote="" />
<type label="MEDIUMINT" length="0" sql="MEDIUMINT" quote="" />
<type label="INT" length="0" sql="INT" quote="" />
<type label="BIGINT" length="0" sql="BIGINT" quote="" />
<type label="Decimal" length="1" sql="DECIMAL" re="DEC" quote="" />
<type label="Single precision" length="0" sql="FLOAT" quote="" />
<type label="Double precision" length="0" sql="DOUBLE" re="DOUBLE" quote="" />
</group>
<group label="Character" color="rgb(255,200,200)">
<type label="Char" length="1" sql="CHAR" quote="'" />
<type label="Varchar" length="1" sql="VARCHAR" quote="'" />
<type label="Text" length="0" sql="MEDIUMTEXT" re="TEXT" quote="'" />
<type label="Binary" length="1" sql="BINARY" quote="'" />
<type label="Varbinary" length="1" sql="VARBINARY" quote="'" />
<type label="BLOB" length="0" sql="BLOB" re="BLOB" quote="'" />
</group>
<group label="Date & Time" color="rgb(200,255,200)">
<type label="Date" length="0" sql="DATE" quote="'" />
<type label="Time" length="0" sql="TIME" quote="'" />
<type label="Datetime" length="0" sql="DATETIME" quote="'" />
<type label="Year" length="0" sql="YEAR" quote="" />
<type label="Timestamp" length="0" sql="TIMESTAMP" quote="'" />
</group>
<group label="Miscellaneous" color="rgb(200,200,255)">
<type label="ENUM" length="1" sql="ENUM" quote="" />
<type label="SET" length="1" sql="SET" quote="" />
<type label="Bit" length="0" sql="bit" quote="" />
</group>
</datatypes>
<table x="863" y="197" name="tests">
<row name="id" null="1" autoincrement="1">
<datatype>INTEGER</datatype>
<default>NULL</default>
</row>
<row name="test_name" null="1" autoincrement="0">
<datatype>INTEGER</datatype>
<default>NULL</default>
</row>
<row name="who" null="1" autoincrement="0">
<datatype>INTEGER</datatype>
<default>NULL</default>
<relation table="users" row="id" />
</row>
<row name="results" null="1" autoincrement="0">
<datatype>INTEGER</datatype>
<default>NULL</default>
<relation table="volumetric_test_results" row="id" />
</row>
<row name="overall_pass" null="1" autoincrement="0">
<datatype>INTEGER</datatype>
<default>NULL</default>
</row>
<key type="PRIMARY" name="">
<part>id</part>
</key>
</table>
<table x="166" y="300" name="test_names">
<row name="id" null="1" autoincrement="1">
<datatype>INTEGER</datatype>
<default>NULL</default>
</row>
<row name="test_name" null="1" autoincrement="0">
<datatype>VARCHAR</datatype>
<default>NULL</default>
</row>
<key type="PRIMARY" name="">
<part>id</part>
</key>
</table>
<table x="1002" y="91" name="machines">
<row name="serial" null="1" autoincrement="1">
<datatype>MEDIUMTEXT</datatype>
<default>NULL</default>
</row>
<row name="part_number" null="1" autoincrement="0">
<datatype>MEDIUMTEXT</datatype>
<default>NULL</default>
<relation table="machine_types" row="part_number" />
</row>
<row name="syringe" null="1" autoincrement="0">
<datatype>INTEGER</datatype>
<default>NULL</default>
<relation table="syringes" row="serial_number" />
</row>
<row name="tests_undertaken" null="1" autoincrement="0">
<datatype>INTEGER</datatype>
<default>NULL</default>
<relation table="tests" row="id" />
</row>
<key type="PRIMARY" name="">
<part>serial</part>
</key>
</table>
<table x="1171" y="17" name="machine_types">
<row name="part_number" null="1" autoincrement="1">
<datatype>MEDIUMTEXT</datatype>
<default>NULL</default>
</row>
<row name="description" null="1" autoincrement="0">
<datatype>MEDIUMTEXT</datatype>
<default>NULL</default>
</row>
<key type="PRIMARY" name="">
<part>part_number</part>
</key>
</table>
<table x="600" y="302" name="volumetric_test_results">
<row name="id" null="1" autoincrement="1">
<datatype>INTEGER</datatype>
<default>NULL</default>
</row>
<row name="plate" null="1" autoincrement="0">
<datatype>INTEGER</datatype>
<default>NULL</default>
<relation table="plates" row="id" />
</row>
<row name="criteria" null="1" autoincrement="0">
<datatype>INTEGER</datatype>
<default>NULL</default>
<relation table="volumetric_test_criteria" row="id" />
</row>
<row name="pass" null="1" autoincrement="0">
<datatype>INTEGER</datatype>
<default>NULL</default>
</row>
<row name="stock_solution" null="1" autoincrement="0">
<datatype>INTEGER</datatype>
<default>NULL</default>
<relation table="stock_solutions" row="id" />
</row>
<key type="PRIMARY" name="">
<part>id</part>
</key>
</table>
<table x="363" y="294" name="volumetric_test_criteria">
<row name="id" null="0" autoincrement="1">
<datatype>INTEGER</datatype>
<default>NULL</default>
</row>
<row name="test_name" null="1" autoincrement="0">
<datatype>INTEGER</datatype>
<default>NULL</default>
<relation table="test_names" row="id" />
</row>
<row name="feature" null="1" autoincrement="0">
<datatype>MEDIUMTEXT</datatype>
<default>NULL</default>
</row>
<row name="criterion" null="1" autoincrement="0">
<datatype>INTEGER</datatype>
<default>NULL</default>
</row>
<row name="volume" null="1" autoincrement="0">
<datatype>INTEGER</datatype>
<default>NULL</default>
</row>
<row name="unit" null="1" autoincrement="0">
<datatype>VARCHAR</datatype>
<default>NULL</default>
</row>
<row name="active" null="1" autoincrement="0">
<datatype>INTEGER</datatype>
<default>NULL</default>
</row>
<row name="use_wells" null="1" autoincrement="0">
<datatype>VARCHAR</datatype>
<default>NULL</default>
</row>
<row name="required_to_pass" null="1" autoincrement="0">
<datatype>INTEGER</datatype>
<default>NULL</default>
</row>
<key type="PRIMARY" name="">
<part>id</part>
</key>
</table>
<table x="1220" y="435" name="wells">
<row name="plate" null="1" autoincrement="0">
<datatype>INTEGER</datatype>
<default>NULL</default>
<relation table="plates" row="id" />
</row>
<row name="well" null="0" autoincrement="0">
<datatype>INTEGER</datatype>
<default>NULL</default>
</row>
<row name="absorbance" null="1" autoincrement="0">
<datatype>DOUBLE</datatype>
<default>NULL</default>
</row>
<key type="PRIMARY" name="" />
</table>
<table x="1217" y="285" name="plates">
<row name="id" null="1" autoincrement="0">
<datatype>INTEGER</datatype>
<default>NULL</default>
</row>
<row name="datetime" null="1" autoincrement="0">
<datatype>DATETIME</datatype>
<default>NULL</default>
</row>
<key type="PRIMARY" name="">
<part>id</part>
</key>
</table>
<table x="623" y="616" name="stock_solutions">
<row name="id" null="1" autoincrement="1">
<datatype>INTEGER</datatype>
<default>NULL</default>
</row>
<row name="plate" null="1" autoincrement="0">
<datatype>INTEGER</datatype>
<default>NULL</default>
<relation table="plates" row="id" />
</row>
<row name="criteria" null="1" autoincrement="0">
<datatype>INTEGER</datatype>
<default>NULL</default>
<relation table="stock_criteria" row="id" />
</row>
<row name="who" null="1" autoincrement="0">
<datatype>INTEGER</datatype>
<default>NULL</default>
<relation table="users" row="id" />
</row>
<row name="pass" null="1" autoincrement="0">
<datatype>INTEGER</datatype>
<default>NULL</default>
</row>
<key type="PRIMARY" name="">
<part>id</part>
</key>
</table>
<table x="398" y="603" name="stock_criteria">
<row name="id" null="1" autoincrement="1">
<datatype>INTEGER</datatype>
<default>NULL</default>
</row>
<row name="mean_square_error" null="1" autoincrement="0">
<datatype>INTEGER</datatype>
<default>NULL</default>
</row>
<row name="slope" null="1" autoincrement="0">
<datatype>INTEGER</datatype>
<default>NULL</default>
</row>
<row name="intercept" null="1" autoincrement="0">
<datatype>INTEGER</datatype>
<default>NULL</default>
</row>
<row name="use_wells" null="1" autoincrement="0">
<datatype>VARCHAR</datatype>
<default>NULL</default>
</row>
<key type="PRIMARY" name="">
<part>id</part>
</key>
</table>
<table x="836" y="47" name="syringes">
<row name="serial_number" null="1" autoincrement="1">
<datatype>INTEGER</datatype>
<default>NULL</default>
</row>
<row name="tests_undertaken" null="1" autoincrement="0">
<datatype>INTEGER</datatype>
<default>NULL</default>
<relation table="syringe_tests" row="id" />
</row>
<key type="PRIMARY" name="">
<part>serial_number</part>
</key>
</table>
<table x="617" y="105" name="syringe_tests">
<row name="id" null="1" autoincrement="1">
<datatype>INTEGER</datatype>
<default>NULL</default>
</row>
<row name="criteria" null="1" autoincrement="0">
<datatype>INTEGER</datatype>
<default>NULL</default>
<relation table="syringe_test_criteria" row="id" />
</row>
<row name="who" null="1" autoincrement="0">
<datatype>INTEGER</datatype>
<default>NULL</default>
<relation table="users" row="id" />
</row>
<row name="pass" null="1" autoincrement="0">
<datatype>INTEGER</datatype>
<default>NULL</default>
</row>
<row name="plate" null="1" autoincrement="0">
<datatype>INTEGER</datatype>
<default>NULL</default>
<relation table="plates" row="id" />
</row>
<key type="PRIMARY" name="">
<part>id</part>
</key>
</table>
<table x="365" y="78" name="syringe_test_criteria">
<row name="id" null="1" autoincrement="1">
<datatype>INTEGER</datatype>
<default>NULL</default>
</row>
<row name="volume" null="1" autoincrement="0">
<datatype>INTEGER</datatype>
<default>NULL</default>
</row>
<row name="unit" null="1" autoincrement="0">
<datatype>INTEGER</datatype>
<default>NULL</default>
</row>
<row name="use_wells" null="1" autoincrement="0">
<datatype>VARCHAR</datatype>
<default>NULL</default>
</row>
<row name="feature" null="1" autoincrement="0">
<datatype>MEDIUMTEXT</datatype>
<default>NULL</default>
</row>
<key type="PRIMARY" name="">
<part>id</part>
</key>
</table>
<table x="711" y="771" name="users">
<row name="id" null="1" autoincrement="1">
<datatype>INTEGER</datatype>
<default>NULL</default>
</row>
<row name="first_name" null="1" autoincrement="0">
<datatype>VARCHAR</datatype>
<default>NULL</default>
</row>
<row name="surname" null="1" autoincrement="0">
<datatype>VARCHAR</datatype>
<default>NULL</default>
</row>
<row name="email" null="1" autoincrement="0">
<datatype>VARCHAR</datatype>
<default>NULL</default>
</row>
<row name="password_hash" null="1" autoincrement="0">
<datatype>VARCHAR</datatype>
<default>NULL</default>
</row>
<row name="role" null="1" autoincrement="0">
<datatype>INTEGER</datatype>
<default>NULL</default>
<relation table="roles" row="id" />
</row>
<key type="PRIMARY" name="">
<part>id</part>
</key>
</table>
<table x="858" y="823" name="roles">
<row name="id" null="1" autoincrement="1">
<datatype>INTEGER</datatype>
<default>NULL</default>
</row>
<row name="role" null="1" autoincrement="0">
<datatype>VARCHAR</datatype>
<default>NULL</default>
</row>
<key type="PRIMARY" name="">
<part>id</part>
</key>
</table>
</sql>
It's very hard to review someone's design in the way you presented. However, I did notice some basic issues:
Your machines table (and others) columns such as tests_undertaken which you indicate is of type int. I don't see how this makes sense. (See below).
You have a tests table, but is that for the "types" of test or specific test runs on specific machines? If it's the former, then you should have a separate table that links the tests table to the machines table that contains a record for each test run on a machine and also links to the test results.
Your test_names table seems unnecessary as there is no additional information provided that doesn't seem to be able to be contained in the volumetric_test_criteria table by simply replacing the name's id with the name itself. The space you save by making the extra table is probably overwhelmed by the overhead of always having to JOIN these two tables.
As others have pointed out, you should read up on database normalization, but I hope this helps get you started.
After trying many answers about how to delete a field from a xml column in SQL, I can't still manage to find a way to delete the same attribute in multiple fields. Currently my xml column looks something like this:
<ArrayOfCodes xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<Code code="001 ">
<price xmlns="http://..." xsi:nil="true" />
<salePrice xmlns="http://..." xsi:nil="true" />
<quantity xmlns="http:/...">1</>
</Code>
<Code code="002 ">
<price xmlns="http://..." xsi:nil="true" />
<salePrice xmlns="http://..." xsi:nil="true" />
<quantity xmlns="http:/...">1</>
</Code>
<Code code="003 ">
<price xmlns="http://..." xsi:nil="true" />
<salePrice xmlns="http://..." xsi:nil="true" />
<quantity xmlns="http:/...">1</>
</Code>
</ArrayOfCodes>
My task is to remove the xmlns attributes in all of the fields. Can you please help me with that?
Can you all help me for this problem?
I want to get value from following XML in sql stored procedure. I don't get vlaue if 'xsi:type="ActiveDirectoryItem"' is in tag 'anyType', and 'ActiveDirectoryItems' tag is also with URLs. How can i do to get only values?
<?xml version="1.0" encoding="utf-8" ?>
<ActiveDirectoryItems xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://tempuri.org/">
<Items>
<anyType xsi:type="ActiveDirectoryItem">
<FirstName />
<MiddleInitial />
<LastName />
<DisplayName>Migrate-group</DisplayName>
<UserPrincipalName />
<PostalAddress />
<ResidentialAddress />
<Title />
<HomePhone />
<OfficePhone />
<Mobile />
<Fax />
<Email>Migrate-group#gmail.com</Email>
<Url />
<AccountName>Migrate-group</AccountName>
<DistinguishedName />
<IsAccountActive>false</IsAccountActive>
<ManagedBy />
<Manager />
<CompareType>0</CompareType>
<Description />
<Department />
<Company />
<Type />
</anyType>
</Items>
<GlobalCatalog />
</ActiveDirectoryItems>
The format i want to get is as the following:
DisplayName Email Account Name
Migrate-group Migrate-group#gmail.com Migrate-group
you can use the value keyword
Example:
DECLARE #MyXml XML = '<Root><SomeData>100</SomeData></Root>'
DECLARE #Something INT
SELECT #Something = #MyXml.value('(//Root/SomeData)[1]', 'INT')