xslt substring help
Here should go questions about transforming XML with XSLT and FOP.
-
- Posts: 9
- Joined: Thu Dec 11, 2008 10:15 pm
xslt substring help
Hello,
I have a xml file below from which I want to extract the data using xslt. I am trying to create the xslt but no results , I have some hard coated values in the xslt which I want in the output xml.
I also need the other values from the below xml file. But I don't know how to separate the special characters.
I want to display the date from the below xml , the last 2 lines in my xml has the date value(testdate), I don't know how to select it and display it in my xslt (just the date) with out the special characters.
Kindly help
XML File :
<DATA>
<TEST_NAME="null" CTO_ZZZ_ID="null" SHIP_DATE="" INVOICE_NUMBER="AT45748"
TEST_XML_DATA="<xml version="1.0" encoding="UTF-8">
	<parent
testType= "T" display="N " gt;
		<
preview></preview>
	<
testificate>
	<
invoicelabel>Invoice Number: </invoicelabel>
	<
invoicenumber>AT45748</invoicenumber>
	<
stocklabel>Stock Number: </stocklabel>
	<
iddesc>60-0200-1496-9 3TA98-AF COND 4.25 IN</iddesc>
	<
testcontent expDisp="false"
testtype="T" font="" locale="en" orderInfoAvlbleFlag="true" previewFont="Arial" testCommDisp="false" cpsiaInvoice="false" optCommentFlag="false" >
		<logo></logo>
		<testtitle locale="en">
		<title>testificate of testing</title>
		</testtitle>
		<exception locale="en">
		<text></text>
		</exception>
		<locationAddress locale="en">
		<firstline1>YYYY</firstline1>
		<secondline1>Bldg 19-01-usa Rd</secondline1>
		<thirdline1>usa 55016</thirdline1>
		</locationAddress>
		<customerAddress locale="en">
		<firstline2>EMA US ACRES</firstline2>
		<secondline2>2222 AVE</secondline2>
		<thirdline2>HILLSBORO OR 971245506 </thirdline2>
		</customerAddress>
		<
testdate locale="en">
		<label>Date testificate is prepared:</label>
		<date>Jun-10-2009</date>
		</testdate >
		<
----
XSLT File:
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="xml" encoding="utf-8" omit-xml-declaration="no" indent="yes" />
<xsl:template match="/">
<xsl:element name="File" namespace="x-schema:../Schema/testificateSchema2001Jul.xml">
<xsl:element name="FileInfo" namespace="x-schema:../Schema/testificateSchema2001Jul.xml">
<xsl:element name="responsiblePartyEmail" namespace="x-schema:../Schema/ChemGasQualitytestificateSchema2001Jul.xml">tom@yahoo.com</xsl:element>
</xsl:element>
<xsl:element name="BusinessSites" namespace="x-schema:../Schema/testificateSchema2001Jul.xml">
<xsl:element name="Description" namespace="x-schema:../Schema/testificateSchema2001Jul.xml">
<xsl:element name="manufacturerNumber" namespace="x-schema:../Schema/testificateSchema2001Jul.xml">678748</xsl:element>
<xsl:element name="manufacturerName" namespace="x-schema:../Schema/testificateSchema2001Jul.xml">TEST</xsl:element>
<xsl:element name="manufacturingPlantCode" namespace="x-schema:../Schema/testificateSchema2001Jul.xml">341403</xsl:element>
<!-- <xsl:element name="incomingFaxNumber"></xsl:element> obsolete /-->
<!--DUNSPlusFour/-->
<xsl:element name="manufacturer" namespace="x-schema:../Schema/testificateSchema2001Jul.xml">TEST1</xsl:element>
<xsl:variable name="testingDate" select="//testdate/date" />
<xsl:variable name="testMonth" select="substring(//testdate/date,1,3)" />
<xsl:variable name="testMonthDigits">
<xsl:choose>
<xsl:when test="$testMonth='Jan'">01</xsl:when>
<xsl:when test="$testMonth='Feb'">02</xsl:when>
<xsl:when test="$testMonth='Mar'">03</xsl:when>
<xsl:when test="$testMonth='Apr'">04</xsl:when>
<xsl:when test="$testMonth='May'">05</xsl:when>
<xsl:when test="$testMonth='Jun'">06</xsl:when>
<xsl:when test="$testMonth='Jul'">07</xsl:when>
<xsl:when test="$testMonth='Aug'">08</xsl:when>
<xsl:when test="$testMonth='Sep'">09</xsl:when>
<xsl:when test="$testMonth='Oct'">10</xsl:when>
<xsl:when test="$testMonth='Nov'">11</xsl:when>
<xsl:when test="$testMonth='Dec'">12</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$testMonth" />
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
</xsl:element>
</xsl:element>
</xsl:element>
</xsl:element>
</xsl:template>
</xsl:stylesheet>
I have a xml file below from which I want to extract the data using xslt. I am trying to create the xslt but no results , I have some hard coated values in the xslt which I want in the output xml.
I also need the other values from the below xml file. But I don't know how to separate the special characters.
I want to display the date from the below xml , the last 2 lines in my xml has the date value(testdate), I don't know how to select it and display it in my xslt (just the date) with out the special characters.
Kindly help
XML File :
<DATA>
<TEST_NAME="null" CTO_ZZZ_ID="null" SHIP_DATE="" INVOICE_NUMBER="AT45748"
TEST_XML_DATA="<xml version="1.0" encoding="UTF-8">
	<parent
testType= "T" display="N " gt;
		<
preview></preview>
	<
testificate>
	<
invoicelabel>Invoice Number: </invoicelabel>
	<
invoicenumber>AT45748</invoicenumber>
	<
stocklabel>Stock Number: </stocklabel>
	<
iddesc>60-0200-1496-9 3TA98-AF COND 4.25 IN</iddesc>
	<
testcontent expDisp="false"
testtype="T" font="" locale="en" orderInfoAvlbleFlag="true" previewFont="Arial" testCommDisp="false" cpsiaInvoice="false" optCommentFlag="false" >
		<logo></logo>
		<testtitle locale="en">
		<title>testificate of testing</title>
		</testtitle>
		<exception locale="en">
		<text></text>
		</exception>
		<locationAddress locale="en">
		<firstline1>YYYY</firstline1>
		<secondline1>Bldg 19-01-usa Rd</secondline1>
		<thirdline1>usa 55016</thirdline1>
		</locationAddress>
		<customerAddress locale="en">
		<firstline2>EMA US ACRES</firstline2>
		<secondline2>2222 AVE</secondline2>
		<thirdline2>HILLSBORO OR 971245506 </thirdline2>
		</customerAddress>
		<
testdate locale="en">
		<label>Date testificate is prepared:</label>
		<date>Jun-10-2009</date>
		</testdate >
		<
----
XSLT File:
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="xml" encoding="utf-8" omit-xml-declaration="no" indent="yes" />
<xsl:template match="/">
<xsl:element name="File" namespace="x-schema:../Schema/testificateSchema2001Jul.xml">
<xsl:element name="FileInfo" namespace="x-schema:../Schema/testificateSchema2001Jul.xml">
<xsl:element name="responsiblePartyEmail" namespace="x-schema:../Schema/ChemGasQualitytestificateSchema2001Jul.xml">tom@yahoo.com</xsl:element>
</xsl:element>
<xsl:element name="BusinessSites" namespace="x-schema:../Schema/testificateSchema2001Jul.xml">
<xsl:element name="Description" namespace="x-schema:../Schema/testificateSchema2001Jul.xml">
<xsl:element name="manufacturerNumber" namespace="x-schema:../Schema/testificateSchema2001Jul.xml">678748</xsl:element>
<xsl:element name="manufacturerName" namespace="x-schema:../Schema/testificateSchema2001Jul.xml">TEST</xsl:element>
<xsl:element name="manufacturingPlantCode" namespace="x-schema:../Schema/testificateSchema2001Jul.xml">341403</xsl:element>
<!-- <xsl:element name="incomingFaxNumber"></xsl:element> obsolete /-->
<!--DUNSPlusFour/-->
<xsl:element name="manufacturer" namespace="x-schema:../Schema/testificateSchema2001Jul.xml">TEST1</xsl:element>
<xsl:variable name="testingDate" select="//testdate/date" />
<xsl:variable name="testMonth" select="substring(//testdate/date,1,3)" />
<xsl:variable name="testMonthDigits">
<xsl:choose>
<xsl:when test="$testMonth='Jan'">01</xsl:when>
<xsl:when test="$testMonth='Feb'">02</xsl:when>
<xsl:when test="$testMonth='Mar'">03</xsl:when>
<xsl:when test="$testMonth='Apr'">04</xsl:when>
<xsl:when test="$testMonth='May'">05</xsl:when>
<xsl:when test="$testMonth='Jun'">06</xsl:when>
<xsl:when test="$testMonth='Jul'">07</xsl:when>
<xsl:when test="$testMonth='Aug'">08</xsl:when>
<xsl:when test="$testMonth='Sep'">09</xsl:when>
<xsl:when test="$testMonth='Oct'">10</xsl:when>
<xsl:when test="$testMonth='Nov'">11</xsl:when>
<xsl:when test="$testMonth='Dec'">12</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$testMonth" />
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
</xsl:element>
</xsl:element>
</xsl:element>
</xsl:element>
</xsl:template>
</xsl:stylesheet>
-
- Site Admin
- Posts: 2095
- Joined: Thu Jan 09, 2003 2:58 pm
Re: xslt substring help
This is a duplicate of http://www.oxygenxml.com/forum/post12465.html
George Cristian Bina
Jump to
- Oxygen XML Editor/Author/Developer
- ↳ Feature Request
- ↳ Common Problems
- ↳ DITA (Editing and Publishing DITA Content)
- ↳ SDK-API, Frameworks - Document Types
- ↳ DocBook
- ↳ TEI
- ↳ XHTML
- ↳ Other Issues
- Oxygen XML Web Author
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Content Fusion
- ↳ Feature Request
- ↳ Common Problems
- Oxygen JSON Editor
- ↳ Feature Request
- ↳ Common Problems
- Oxygen PDF Chemistry
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Feedback
- ↳ Feature Request
- ↳ Common Problems
- Oxygen XML WebHelp
- ↳ Feature Request
- ↳ Common Problems
- XML
- ↳ General XML Questions
- ↳ XSLT and FOP
- ↳ XML Schemas
- ↳ XQuery
- NVDL
- ↳ General NVDL Issues
- ↳ oNVDL Related Issues
- XML Services Market
- ↳ Offer a Service