Namespace Parsing Problem
-
I’m new to XSL and struggling with this for awhile. Hope someone can take a look at my code and provide me with your feedback. The output looks close to what I want, but it’s not quite there yet. I’m looking for certain attributes (id=GUIDs) in ‘task’ element and copy the entire ‘task’ element if the attribute is matched with what I’m looking for. However the namespace cannot be copied correctly. Basically I don’t want the output to have the reference “:det” in taskGroup element and xmlns=http://schemas... in task element. How do I do this? Please see the source xml, xsl, current incorrect output and expected output below. Thank you in advance! Source XML:
<?xml version="1.0" encoding="utf-8"?>
<taskGroup revocation="false" taskGroupGuid="{a0949a60-006c-4b35-b334-97ca289b06cd}" xmlns="http://schemas.microsoft.com/windows/2008/deviceExperienceTasks">
<tasks>
<task id="{f418cae0-6b68-409b-93f4-a19fa1a5faad}" rank="2" name="1" description="2" tooltip="2" >
<command type="ShellExecute">
<arguments>
<commandLine>www.xxxxxx.com</commandLine>
</arguments>
</command>
</task>
<task id="{91395410-c164-468c-a247-14bbd7ceea88}" rank="5" issueTime="2009-09-15T11:05:42Z" requiresElevation="false" name="3" description="4" tooltip="4" >
<command type="ShellExecute">
<arguments>
<commandLine>www.yyyyyy.com</commandLine>
</arguments>
</command>
</task>
</tasks>
</taskGroup>
...
...
...XSL:
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl" xmlns:det="http://schemas.microsoft.com/windows/2008/deviceExperienceTasks"<xsl:output method="xml" indent="yes"/>
<xsl:template match="/">
<taskGroup revocation="false" taskGroupGuid="{{a0949a60-006c-4b35-b334-97ca289b06cd}}" >
<xsl:call-template name="taskList"></xsl:call-template>
</taskGroup>
</xsl:template>
<xsl:template name="taskList">
<xsl:copy-of select="//det:task[@id='{91395410-c164-468c-a247-14bbd7ceea88}']"/>
</xsl:template>
</xsl:stylesheet>Current Output (incorrect):
<?xml version="1.0" encoding="utf-8"?>
< -
I’m new to XSL and struggling with this for awhile. Hope someone can take a look at my code and provide me with your feedback. The output looks close to what I want, but it’s not quite there yet. I’m looking for certain attributes (id=GUIDs) in ‘task’ element and copy the entire ‘task’ element if the attribute is matched with what I’m looking for. However the namespace cannot be copied correctly. Basically I don’t want the output to have the reference “:det” in taskGroup element and xmlns=http://schemas... in task element. How do I do this? Please see the source xml, xsl, current incorrect output and expected output below. Thank you in advance! Source XML:
<?xml version="1.0" encoding="utf-8"?>
<taskGroup revocation="false" taskGroupGuid="{a0949a60-006c-4b35-b334-97ca289b06cd}" xmlns="http://schemas.microsoft.com/windows/2008/deviceExperienceTasks">
<tasks>
<task id="{f418cae0-6b68-409b-93f4-a19fa1a5faad}" rank="2" name="1" description="2" tooltip="2" >
<command type="ShellExecute">
<arguments>
<commandLine>www.xxxxxx.com</commandLine>
</arguments>
</command>
</task>
<task id="{91395410-c164-468c-a247-14bbd7ceea88}" rank="5" issueTime="2009-09-15T11:05:42Z" requiresElevation="false" name="3" description="4" tooltip="4" >
<command type="ShellExecute">
<arguments>
<commandLine>www.yyyyyy.com</commandLine>
</arguments>
</command>
</task>
</tasks>
</taskGroup>
...
...
...XSL:
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl" xmlns:det="http://schemas.microsoft.com/windows/2008/deviceExperienceTasks"<xsl:output method="xml" indent="yes"/>
<xsl:template match="/">
<taskGroup revocation="false" taskGroupGuid="{{a0949a60-006c-4b35-b334-97ca289b06cd}}" >
<xsl:call-template name="taskList"></xsl:call-template>
</taskGroup>
</xsl:template>
<xsl:template name="taskList">
<xsl:copy-of select="//det:task[@id='{91395410-c164-468c-a247-14bbd7ceea88}']"/>
</xsl:template>
</xsl:stylesheet>Current Output (incorrect):
<?xml version="1.0" encoding="utf-8"?>
<You have to have the namespace declaration somewhere/somehow - the task element in the output has been copied verbatim from the input, where it lived in the det/http://schemas.microsoft.com/windows/2008/deviceExperienceTasks namespace. What output do you WANT to see?
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
-
I’m new to XSL and struggling with this for awhile. Hope someone can take a look at my code and provide me with your feedback. The output looks close to what I want, but it’s not quite there yet. I’m looking for certain attributes (id=GUIDs) in ‘task’ element and copy the entire ‘task’ element if the attribute is matched with what I’m looking for. However the namespace cannot be copied correctly. Basically I don’t want the output to have the reference “:det” in taskGroup element and xmlns=http://schemas... in task element. How do I do this? Please see the source xml, xsl, current incorrect output and expected output below. Thank you in advance! Source XML:
<?xml version="1.0" encoding="utf-8"?>
<taskGroup revocation="false" taskGroupGuid="{a0949a60-006c-4b35-b334-97ca289b06cd}" xmlns="http://schemas.microsoft.com/windows/2008/deviceExperienceTasks">
<tasks>
<task id="{f418cae0-6b68-409b-93f4-a19fa1a5faad}" rank="2" name="1" description="2" tooltip="2" >
<command type="ShellExecute">
<arguments>
<commandLine>www.xxxxxx.com</commandLine>
</arguments>
</command>
</task>
<task id="{91395410-c164-468c-a247-14bbd7ceea88}" rank="5" issueTime="2009-09-15T11:05:42Z" requiresElevation="false" name="3" description="4" tooltip="4" >
<command type="ShellExecute">
<arguments>
<commandLine>www.yyyyyy.com</commandLine>
</arguments>
</command>
</task>
</tasks>
</taskGroup>
...
...
...XSL:
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl" xmlns:det="http://schemas.microsoft.com/windows/2008/deviceExperienceTasks"<xsl:output method="xml" indent="yes"/>
<xsl:template match="/">
<taskGroup revocation="false" taskGroupGuid="{{a0949a60-006c-4b35-b334-97ca289b06cd}}" >
<xsl:call-template name="taskList"></xsl:call-template>
</taskGroup>
</xsl:template>
<xsl:template name="taskList">
<xsl:copy-of select="//det:task[@id='{91395410-c164-468c-a247-14bbd7ceea88}']"/>
</xsl:template>
</xsl:stylesheet>Current Output (incorrect):
<?xml version="1.0" encoding="utf-8"?>
<I used a namespace reference ":det" in the xls ("xmlns:det="http://schemas.microsoft.com/windows/2008/deviceExperienceTasks"), but I want to see the namespace in the output without the reference. There is also extra namespace appears in the end of the 'task' element which I don't want.
-
I used a namespace reference ":det" in the xls ("xmlns:det="http://schemas.microsoft.com/windows/2008/deviceExperienceTasks"), but I want to see the namespace in the output without the reference. There is also extra namespace appears in the end of the 'task' element which I don't want.
Why does it make any difference? Semantically, both forms are exactly the same.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p